main.asc
来自「FlexChat聊天室」· ASC 代码 · 共 53 行
ASC
53 行
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 + =
减小字号Ctrl + -
显示快捷键?