Skip to main content
Known Participant
Sep 30, 2009 5:13 PM UTC
Answered

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

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 is closed to new replies. Start a new post to keep the conversation going.
    Correct answer
    Sep 30, 2009 5:43 PM UTC

    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.

    2 replies

    Correct answer
    Sep 30, 2009 5:43 PM UTC

    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.

    Translate
    Known Participant
    Sep 30, 2009 6:14 PM UTC

    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.

    Translate