Page 1 of 1

privateMessage and receiver

Posted: 08 Oct 2010, 06:38
by gsources75
Ok i write an example.

There are 2 user in room.

fox1 and fox2. I'm fox1.

i send a private message.

smartFox.sendPrivateMessage("ciao",id, room);

ok it works but on event

private function onPrivateMessage(event : SFSEvent) : void {

i can know only sender i know "from" and not "to".

i test here, all users receive identic message.

fox1 send a private message.

Iis it correct ?

is there a method to know the receiver ?

Posted: 08 Oct 2010, 15:11
by TiagoR

Code: Select all

smartFox.sendPrivateMessage (message, recipientId, roomId)

// message (String) : the text of the private message.
// recipientId (int) : the id of the recipient user.
// roomId (int): the id of the room from where the message is sent, in case of multi-room join (optional, default value: activeRoomId).

Code: Select all

function onPrivateMessage(evt:SFSEvent):void
{
    trace("User " + evt.params.sender.getName() + " sent the following private message: " + evt.params.message)
}
Traces the user that sent the message and the message text. The only one that receives the message is the recipientId user. All others users dont. So there is no need for a method to know the receiver, since its only him that receives.