Page 1 of 1

Send to all in room AS extension

Posted: 10 Sep 2010, 17:50
by pilot
Hi there,

I've written a function that most of my code depends on that sends a message to everyone in the room. Take a look:

Code: Select all

function sendToRoom(resp, fromRoom, sender, recipients)
{
    var room = _server.getCurrentRoom();
    _server.sendResponse(resp, fromRoom, sender, room.getAllUsers());
}
Am I doing something incorrectly? I keep getting a method cannot be called on getAllUsers() on my object. Can't seem to find any samples that make use of the getAllUsers() method.

Thanks.

Posted: 10 Sep 2010, 20:58
by BigFIsh
Is this script located in one of your room extension? (since _server.getCurrentRoom() only works in a room extension)

Posted: 11 Sep 2010, 19:24
by pilot
Well the silly thing is that I've written a single extension that gets used when the user first joins then when they join a room. When the person actually makes the request it IS inside a room (thus I assume it's acting as a room extension at that moment?).

Posted: 11 Sep 2010, 20:42
by BigFIsh
Sounds like you are dynamically attaching an extension to a room upon creation or the extension was defined in your <room> tags at boot time - in this case, yes - it is a room extension.

A zone extension is located outside the <rooms> scope, but inside the <zone> tag.