Page 1 of 1

sendObjectMessage questions

Posted: 15 Jul 2011, 00:53
by jurekf
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?

Posted: 17 Jul 2011, 16:21
by Lapo
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.

Posted: 18 Jul 2011, 00:59
by jurekf
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.