0

I am a new user member here. And i am new to FMS. I have a question i would like to ask in regards to sending text data messages in a live video chat app from one user to another. I am wanting to create a video chat application using Flash Media Server with rtmfp. I would like my users to send messages back and forth in a one to one chat private room rather than sending data to everyone subscribed in a group for example. I was considering using a remote ShardeObject for this however, the SharedObjects broadcasts messages to all members which is not what i want. Question, can you use a sharedobject to send data messages to a specific client or, should i be really looking towards using a NetStream.send method or NetGroup's sendToNearest methods? Thanks Ashley

1 Answers1

0

You could use different shared objects, creating a new one every time there is a new chat between two users.

But another option is to use the call() method of your NetConnection.

Provided that you implemented a method 'sendMessage()' on your server like this:

Client.prototype.sendMessage = function(clientID, message)
{
    for (var i = 0; i < application.clients.length; i++)
    {
        var client = application.clients[i];
        if (client.id === clientID)
        {
            client.call("handleMessage", null, message);
        }
    }
}

You can then do this on the client side:

    connection.client = this;

[...]

public function sendMessage(message:String):void
{
    connection.call("sendMessage", null, clientID, message);
}

public function handleMessage(message:String):void
{
    // message sent from server
}
duTr
  • 714
  • 5
  • 21