sendObjectMessage questions

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

jurekf
Posts: 69
Joined: 08 Dec 2010, 23:46

sendObjectMessage questions

Postby jurekf » 15 Jul 2011, 00:53

Its behaviour a bit inconsistent; in a handler it seems to not send the object message back to the sender. If it's called in a separate thread however, the sender does seem to get the message as well.

Also, is there some way to mimic having a null sender for the cases where the message originates from the server, without having to do something like:

Code: Select all

if( getRoom().getUserList().size() > 0 )
{
    sendObjectMessage( room, room.getUserList()[0],  sfsobject,  room.getUserList() )
}


instead of just:

Code: Select all

sendObjectMessage( room, null, sfsobject );


which is much easier to read and works even if the room is empty?
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 17 Jul 2011, 16:21

If UserA wants to send data to UserB why would he need to receive that same data back? He already knows it. It's a waste of resources.
It's a different thing from a regular chat message.
With chat messages you want it back so that you don't have to handle your messages differently from other people messages, in regards to showing them on screen.

No it's not possible to send them with a null user because this is a client side feature. If you want to send them from server side simply use an Extension.
Lapo
--
gotoAndPlay()
...addicted to flash games
jurekf
Posts: 69
Joined: 08 Dec 2010, 23:46

Postby jurekf » 18 Jul 2011, 00:59

No, the code I posted shows sendObjectMessage originating from the server in an extension. It's not a waste of resources to send it to UserA because the message did not originate from him.

I could of course just replace it with sendMessageExtension. I was just curious why the second form wasn't implemented considering the API allows a number of functions to specify null when the source is the server and there's nothing intrinsic in a server-originated sendObjectMessage call that requires a source user.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 93 guests