📄 main.asc
字号:
Client.prototype.getServerTime = function(msg){
var now = new Date();
return now.toString();
}
application.onAppStart = function()
{
trace("Begin sharing text");
// Get the server shared object 'users_so'
application.users_so = SharedObject.get("ChatUsers");
// Initialize the history of the text share
application.history = "";
// Initialize the unique user ID
application.nextId = 0;
}
application.onConnect = function(newClient, userName)
{
// Make this new client's name the user's name
newClient.name = userName;
// Create a unique ID for this user while incrementing the
// application.nextID.
newClient.id = "u" + application.nextId++;
// Update the 'users_so' shared object with the user's name
application.users_so.setProperty(newClient.name, userName);
// Accept the client's connection
application.acceptConnection(newClient);
// Call the client function 'setHistory,' and pass
// the initial history
newClient.call("setHistory", null, application.history);
// The client will call this function to get the server
// to accept the message, add the user's name to it, and
// send it back out to all connected clients.
newClient.msgFromClient = function(msg) {
msg = userName + ": " + msg + "\n";
application.history += msg;
application.users_so.send("msgFromSrvr", msg);
}
}
application.onDisconnect = function(client)
{
trace("disconnect: " + client.name);
application.users_so.setProperty(client.name, null);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -