Page 1 of 1

Send a message to a known user

Posted: 06 Jul 2011, 13:24
by eventdave
I have some code in my server side extension that needs to send a response to a known user in a known room, i.e user roomMaster in room myRoom.

How would I send a message to this particular user, as _server.sendResponse() requires a user object. How do I find a particular user?

Many thanks

Dave

Posted: 06 Jul 2011, 18:08
by Nelagend
If you have the ID, you can use _server.getUserById(id). Getting them from their name is a bit more complicated. When that user first joins the room myRoom, it will generate a userJoin internal event with a parameter called params.user that is the actual user object. If you add them to an array of users indexed by user name, you can then use that array as a substitute for the nonexistent (I believe) getUserByName function.

At least some of the examples have the exact code for generating this array.