Skip to main content
June 3, 2007
Question

one to one chat

  • June 3, 2007
  • 1 reply
  • 202 views
Hi, I am currently creating a chat solution that is only consisting of private chats, there is no need for a lobby, the clients should connect to the server, pass on the id of the person they want to connect to, and a SSAS should pass on the messages to the right client.
Am not sure how to resolve this, I think a remotly dshared object might do the trick, but would ask for a short hint in which diredtion I should continue to find an answer

cheers
    This topic has been closed for replies.

    1 reply

    June 4, 2007
    You could use a remote SharedObject. In that case you wouldn't need to pass in the user to connect to in the SSAS at all -- just append an object to the remote SO that identifies the intended recipient. Then onSync check if you are the intended recipient, and if not, discard(do nothing), otherwise show the message.

    However, it would probably be better to do just the opposite, use all SSAS and don't use a SharedObject at all. To do that, you could initialize an object/array onAppStart, like this:

    application.onAppStart = function(){
    this.userList = {};
    }

    Then put new logged in users there:
    application.onConnect = function(newClient,username){
    if(!this.userList[username])this.userList[username] = newClient;
    }

    Then create a function to send private messages:
    Client.prototype.sendMessage = function(msg,to){
    application.userList[to].receiveMessage(msg);
    }

    Then on the client .swf, add a function on your NetConnection called "receiveMessage" that takes the message as a string and do what you want with it. Done!