Skip to main content
Known Participant
September 30, 2009
Answered

main.asc TypeError trying to set a shared object property in application.onConnect

  • September 30, 2009
  • 1 reply
  • 823 views

FMS 3.5.

Basically trying to update a "userlist" shared object everytime someone connects.

Administration console live log reads:

"Sending error message: ...\main.asc: line 12: TypeError: this.usersSO has no properties"

I'm connected ok.  Here's the server code.  Doesn't like "usersSO.setProperty()" call:

application.onAppStart = function()
{
    this.uniqueID=1;
    this.users = new Object();
    this.usersSo = SharedObject.get("userlist", false);   
}

application.onConnect = function(client) {
    application.acceptConnection(client);
    client.call("setUserID", null, this.uniqueID);
    this.users["user_" + this.uniqueID] = client;
    this.usersSO.setProperty("user_" + this.uniqueID, client);       
    this.uniqueID++;
}

    This topic has been closed for replies.
    Correct answer

    Typo. You defined the SO as this.usersSo (lower case o at the end), but in your onconnect, you reference it as this.usersSO (upper case O).

    Also, you might want to reconsider storing the client object as the SO property value. The client object has a ton of properties and methods that you don't need to sync to other clients. You'd likely be better served creating a new object with just the properties you need to sync, and store that as the value of the SO property.

    1 reply

    Correct answer
    September 30, 2009

    Typo. You defined the SO as this.usersSo (lower case o at the end), but in your onconnect, you reference it as this.usersSO (upper case O).

    Also, you might want to reconsider storing the client object as the SO property value. The client object has a ton of properties and methods that you don't need to sync to other clients. You'd likely be better served creating a new object with just the properties you need to sync, and store that as the value of the SO property.

    Known Participant
    September 30, 2009

    DOH!!  My apologies.  Cluttering up the board here with something I should have caught.

    And excellent advice on more efficient synchronization.  I'm on it.

    Thanks.