new SubscribeRoomGroupRequest(groupId)

Creates a new SubscribeRoomGroupRequest instance. The instance must be passed to the SmartFox.send() method for the request to be executed.

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.

Example

This 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.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);
}

Parameter

Name Type Optional Description

groupId

 

 

The name of the Room Group to subscribe.

See also
SmartFox#send
SFSRoom#groupId
SFSEvent.ROOM_GROUP_SUBSCRIBE
SFSEvent.ROOM_GROUP_SUBSCRIBE_ERROR
UnsubscribeRoomGroupRequest