📄 simpleconnect.asc
字号:
/** * Copyright ?2002 Macromedia, Inc. All rights reserved. * * simpleconnect.asc * Moving or modifying this file may affect the applications installed on this server. */try { var dummy = FCSimpleConnect; } catch ( e ) { // #ifndef FCSimpleConnect load( "components/component.asc" ); // // Simple Connect component class // FCSimpleConnect = function(name) { this.init(name); // Get a non persistent shared object for the list of users this.users_so = SharedObject.get( this.prefix + "users", false ); } // All named instances are held in instances FCSimpleConnect.prototype = new FCComponent("FCSimpleConnect", FCSimpleConnect); FCSimpleConnect.prototype.users_so = null; // Users SharedObject /////////////////////////////////////////////////////////////////////////// // onXXX events that are called at appropriate times // This is called when a client disconnects FCSimpleConnect.prototype.onDisconnect = function( client ) { // get per client global storage var clocal = this.getClientLocalStorage(client); this.users_so.setProperty(clocal.id, null); // Need to call this at the end since we are overriding // the base onDisconnect this.releaseLocalStorage(client); } /////////////////////////////////////////////////////////////////////////// // Methods that a client side component calls explicitly // The first method called by a client component FCSimpleConnect.prototype.connect = function( client, userLevel, username, userSex) { var clocal = this.getClientLocalStorage(client); var cglobal = this.getClientGlobalStorage(client); cglobal.username = username; clocal.id = "u" + this.getClientID(client); //this.users_so.setProperty(clocal.id, cglobal.username); this.users_so.setProperty(client.id, {level:userLevel, name:username, sex:userSex}); //trace("Client Connecting: " + clocal.id + ", " + cglobal.username); return clocal.id; } // The last method called by a client component FCSimpleConnect.prototype.close = function( client ) { } FCSimpleConnect.prototype.clientIP = function( client ) { return client.ip; } /////////////////////////////////////////////////////////////////////////// // Helper and utility methods FCSimpleConnect.prototype.changeName = function(client, newName) { //trace("New Name: " + newName); this.getClientGlobalStorage(client).username = newName; client.call(this.callPrefix + "changedName", null, newName); } trace( "SimpleConnect loaded successfully." );} // #endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -