Skip to main content
Participating Frequently
August 18, 2009
Question

FMS's asc code problem

  • August 18, 2009
  • 1 reply
  • 1397 views

Recently, I have writed a section of  FMS server-side code about online user list in ain. But when I loaded an app instance, it would be

immediately  unloaded. I think my code's problem causes it. Can someone help me?
My code is as follow:
var onlineUserSO;
var onlineExpertSO;
application.onAppStart = function()
{
onlineUserSO = SharedObject.get("OnlineUserSO",true);
onlineExpertSO = SharedObject.get("OnlineExpertSO",true);
trace("onAppStart() has been called!");
}
application.onConnect = function(client, userName, userType, isBusy)
{
application.acceptConnection(client);
client.userType = userType;
client.userName = userName;
if(userType == "诊断用户")
{
   trace("当前登录诊断用户: " + userName + " ,状态: " + isBusy);
   var userList = []; //也可以用new Array()不过这个效率更高
   if(onlineUserSO.data.userCollection != null)
      userList = (Object)onlineUserSO.data.userCollection;
   var userObj = new Object();
   userObj["loginedName"] = userName;
   userObj["loginType"] = loginType;
   userObj["isBusy"] = isBusy;
   userList.push(userObj);
   onlineUserSO.setProperty (userCollection, userList);  
}
else
{
   trace("当前登录专家: " + userName + " ,状态: " + isBusy);
   var expertList = []; //也可以用new Array()不过这个效率更高
   if(onlineExpertSO.data.expertCollection != null)
      expertList = (Object)onlineExpertSO.data.expertCollection;
   var expertObj = new Object();
   expertObj["loginedName"] = userName;
   expertObj["loginType"] = loginType;
   expertObj["isBusy"] = isBusy;
   expertList.push(expertObj);
   onlineExpertSO.setProperty (expertCollection, expertList);
}
trace("onConnect() has been called!");
}
application.onDisconnect = function(client)
{
if(client.userType == "诊断用户")
{
   var userList = []; //也可以用new Array()不过这个效率更高
   if(onlineUserSO.data.userCollection != null)
   {
      userList = (Object)onlineUserSO.data.userCollection;
      for(var i = 0; i<userList.length; i++)
      {
        var userObj = new Object();
        userObj = (Object)userList;
        if(userObj["loginedName"].toString() == client.userName)
           userList.splice(i,1);
      }
      onlineUserSO.setProperty (userCollection, userList); 
   }
  
   trace("清除诊断用户 : " + client.userName + " 成功!"); 
}
else
{
   var expertList = []; //也可以用new Array()不过这个效率更高
   if(onlineExpertSO.data.expertCollection != null)
   {
      expertList = (Object)onlineExpertSO.data.expertCollection;
      for(var i = 0; i<expertList.length; i++)
      {
         var expertObj = new Object();
         expertObj = (Object)expertList;
         if(expertObj["loginedName"].toString() == client.userName)
            expertList.splice(i,1);
      }
      onlineExpertSO.setProperty (expertCollection, expertList); 
   }
   trace("清除专家 : " + client.userName + " 成功!");   
}
trace("onDisconnect() has been called!");
}
    This topic has been closed for replies.

    1 reply

    August 18, 2009

    If it's a syntax error, FMS will log a message about it. In your FMS installation directory, see logs/[application name]/[instance name]/application.00.log . The error should be at the bottom of the file.

    MHuatingAuthor
    Participating Frequently
    August 20, 2009

    Thanks a lot! With your help , the problenm has been solved.