Skip to main content
Known Participant
April 15, 2010
Answered

application.clients[client.id].call - not working??...

  • April 15, 2010
  • 1 reply
  • 1678 views

i need a wey without knowing the index value of spacific client in the application clients array

to identify this user for use:

application.clients[this client id].call

to him only.

in addobe halp its says:

"Do not use the index value of the clients array to identify users between calls, because the array is compacted when users disconnect and the slots are reused by other Client objects"

but it do not say what to use??...

i try this 4 ways none working - last 2 throw error:

application.onConnect = function(client)
{

     application.userId = client.id;

     application.clients[application.userId].call("serverDoDisconect");

     application.clients["" + application.userId + ""].call("serverDoDisconect");
     application[application.userId].call("serverDoDisconect");
     application.userId.call("serverDoDisconect");

}

at the moment i use not a good solution:

application.onConnect = function(client)
{

     client.name = "user";

     for (i = 1; i < application.clients.length; i++)
     {
         if(application.clients.name == "user")
         {
          application.clients.call("serverDoDisconect");
         }
    }

}

please halp

thanks

cheinan

    This topic has been closed for replies.
    Correct answer calmchessplayer

    I pass in the clients name through the netConnection URI  on the client side to  onConnect on the serverside and put the name in a object on the serverside and then call  like this. this is untested so you may have to tweak it particulary  this.acceptConnection(client);

    //client side

    nc1.createNetConnection("rtmp://domainname/test/ins0",userName);

    serverside

    application.onAppStart = function()
    {

    this.userObj = new Object();

    }

    application.onConnect = function(client,userName) {

    client.userName1=userName;
    this.userObj[client.userName1]= client;

    this.acceptConnection(client);

    application.userObj["joe"].call("serverDoDisconect");

    }

    1 reply

    Adobe Employee
    April 17, 2010

    Hi,

    The below code works for me.

    Server side code :

    var nc = new NetConnection;
    application.onConnect = function(client) {
          application.acceptConnection(client);
          application.clients[client.id].call("serverDoDisconect");
    }

    Client side code :

    nc = new NetConnection();
    nc.onStatus = function(info){
          trace(info.code);
    }
    nc.connect("rtmp://localhost/test");
    nc.serverDoDisconect = function(){
          trace("serverDoDisconect...");
    }

    Please note that when we do clientObject.call then the method "serverDoDisconect" is called on client's NetConnection object.

    So Its needed to be declared on client as above.

    Regards,

    Amit

    calmchessplayer
    calmchessplayerCorrect answer
    Inspiring
    April 17, 2010

    I pass in the clients name through the netConnection URI  on the client side to  onConnect on the serverside and put the name in a object on the serverside and then call  like this. this is untested so you may have to tweak it particulary  this.acceptConnection(client);

    //client side

    nc1.createNetConnection("rtmp://domainname/test/ins0",userName);

    serverside

    application.onAppStart = function()
    {

    this.userObj = new Object();

    }

    application.onConnect = function(client,userName) {

    client.userName1=userName;
    this.userObj[client.userName1]= client;

    this.acceptConnection(client);

    application.userObj["joe"].call("serverDoDisconect");

    }

    cheinanAuthor
    Known Participant
    April 18, 2010

    thanks a lot calmchessplayer

    problom solved

    i used your solution and its working fine:

    application.onAppStart = function()
    {
          application.userObj = new Object();
    }

    application.onConnect = function(client, theID)
    {
          application.acceptConnection(client);
          application.userObj[theID] = client;

         client.serverConfirmChat = function( userID )
         {
          application.userObj[userID].call("serverShowConfirmChat");
         }
    }

    thanks

    cheinan