Class SFS2X.Requests.System.SubscribeRoomGroupRequest
Subscribes the current user to Room-related events occurring in the specified Group.
Constructor Attributes | Constructor Name and Description |
---|---|
Creates a new SubscribeRoomGroupRequest instance.
|
Class Detail
SFS2X.Requests.System.SubscribeRoomGroupRequest(groupId)
Creates a new SubscribeRoomGroupRequest instance.
The instance must be passed to the SmartFox.send() method for the request to be performed.
This request allows the user to be notified of specific Room events even if he didn't join the Room from which the events originated, provided the Room belongs to the subscribed Group.
If the subscription operation is successful, the current user receives a roomGroupSubscribe event; otherwise the roomGroupSubscribeError event is fired.
The following example makes the current user subscribe a Group:
function someMethod() { sfs.addEventListener(SFS2X.SFSEvent.ROOM_GROUP_SUBSCRIBE, onGroupSubscribed, this); sfs.addEventListener(SFS2X.SFSEvent.ROOM_GROUP_SUBSCRIBE_ERROR, onGroupSubscribeError, this); // Subscribe the "cardGames" group sfs.send(new SFS2X.Requests.System.SubscribeRoomGroupRequest("cardGames")); } function onGroupSubscribed(evtParams) { console.log("Group subscribed. The following rooms are now accessible: " + evtParams.newRooms); } function onGroupSubscribeError(evtParams) { console.log("Group subscription failed: " + evtParams.errorMessage); }
- Parameters:
- {String} groupId
- The name of the Room Group to subscribe.