Answered
a bit bamboozled on client.call
Ive put together a simple client-server app that seems to be
mostly working. Only problem is the "client.call" in the
application.onConnect is not calling the function on the client.
this is in my main.asc:
---------------------------------------------------------------------------------
application.onConnect = function (client, name)
{
// find next available ID
var i = 0;
var tempObj = users_so.getProperty("u"+i);
while(tempObj != null)
{
i++;
tempObj = users_so.getProperty("u"+i);
}
// Save the ID in the client object
client.id = "u"+i;
// add user to SO (this will trigger an onSync on the clients)
users_so.setProperty(client.id, name); // name
users_so.setProperty("lastClient", name); // name
// accept the connection
application.acceptConnection(client); // this works - onStatus is called with NetConnection.Connect.Success
// Tell this client what their ID is
client.call("setID", null, client.id); // doesn't seem to do anything
}
----------------------------------------------------------------------------------------
and this is in my client:
----------------------------------------
my_nc.setID = function (id)
{
myID = id;
statusInput.text += "Online. Your id is " + myID; // never gets executed
};
---------------------------------------
Even though the onStatus gets called with "Success", the code client.call("setID", null, client.id); doesn't call the client's setID function.
And another question: What does client.id = "u"+i; suppose to do? Is that setting the id in a copy of the client on the server, or is it actually supposed to set a variable named "id" on the actual client? If so, then what is client.call("setID", null, client.id); for?
this is in my main.asc:
---------------------------------------------------------------------------------
application.onConnect = function (client, name)
{
// find next available ID
var i = 0;
var tempObj = users_so.getProperty("u"+i);
while(tempObj != null)
{
i++;
tempObj = users_so.getProperty("u"+i);
}
// Save the ID in the client object
client.id = "u"+i;
// add user to SO (this will trigger an onSync on the clients)
users_so.setProperty(client.id, name); // name
users_so.setProperty("lastClient", name); // name
// accept the connection
application.acceptConnection(client); // this works - onStatus is called with NetConnection.Connect.Success
// Tell this client what their ID is
client.call("setID", null, client.id); // doesn't seem to do anything
}
----------------------------------------------------------------------------------------
and this is in my client:
----------------------------------------
my_nc.setID = function (id)
{
myID = id;
statusInput.text += "Online. Your id is " + myID; // never gets executed
};
---------------------------------------
Even though the onStatus gets called with "Success", the code client.call("setID", null, client.id); doesn't call the client's setID function.
And another question: What does client.id = "u"+i; suppose to do? Is that setting the id in a copy of the client on the server, or is it actually supposed to set a variable named "id" on the actual client? If so, then what is client.call("setID", null, client.id); for?
