Packagecom.smartfoxserver.v2.requests
Classpublic class SubscribeRoomGroupRequest
InheritanceSubscribeRoomGroupRequest Inheritance com.smartfoxserver.v2.requests.BaseRequest

Subscribes the current user to Room-related events occurring in the specified Group. This 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.

View the examples

See also

roomGroupSubscribe event
roomGroupSubscribeError event
UnsubscribeRoomGroupRequest


Public Methods
 MethodDefined By
  
Creates a new SubscribeRoomGroupRequest instance.
SubscribeRoomGroupRequest
Constructor Detail
SubscribeRoomGroupRequest()Constructor
public function SubscribeRoomGroupRequest(groupId:String)

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

Parameters
groupId:String — The name of the Room Group to subscribe.

See also

Examples
The following example makes the current user subscribe a Group:
     
     private function someMethod():void
     {
         sfs.addEventListener(SFSEvent.ROOM_GROUP_SUBSCRIBE, onGroupSubscribed);
         sfs.addEventListener(SFSEvent.ROOM_GROUP_SUBSCRIBE_ERROR, onGroupSubscribeError);
         
         // Subscribe the "cardGames" group
         sfs.send(new SubscribeRoomGroupRequest("cardGames"));
     }
     
     private function onGroupSubscribed(evt:SFSEvent):void
     {
         trace("Group subscribed. The following rooms are now accessible: " + evt.params.newRooms);
     }
     
     private function onGroupSubscribeError(evt:SFSEvent):void
     {
         trace("Group subscription failed: " + evt.params.errorMessage);
     }