Click or drag to resize

SubscribeRoomGroupRequest Class

Subscribes the current user to Room-related events occurring in the specified Group.
Inheritance Hierarchy
SystemObject
  BaseRequest
    Sfs2X.RequestsSubscribeRoomGroupRequest

Namespace:  Sfs2X.Requests
Assembly:  SmartFox2X (in SmartFox2X.dll) Version: 1.8.0.0 (1.8.0)
Syntax
C#
public class SubscribeRoomGroupRequest : BaseRequest

The SubscribeRoomGroupRequest type exposes the following members.

Constructors
  NameDescription
Public methodSubscribeRoomGroupRequest
Creates a new SubscribeRoomGroupRequest instance.
Top
Remarks
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 ROOM_GROUP_SUBSCRIBE event; otherwise the ROOM_GROUP_SUBSCRIBE_ERROR event is fired.

Examples
The following example makes the current user subscribe a Group:
void SomeMethod() {
    sfs.AddEventListener(SFSEvent.ROOM_GROUP_SUBSCRIBE, OnSubscribeRoomGroup);
    sfs.AddEventListener(SFSEvent.ROOM_GROUP_SUBSCRIBE_ERROR, OnSubscribeRoomGroupError);

    // Subscribe the "card_games" group
    sfs.Send( new SubscribeRoomGroupRequest("card_games") );
}

void OnSubscribeRoomGroup(BaseEvent evt) {
    Console.WriteLine("Group subscribed. The following rooms are now accessible: " + (List<Room>)evt.Params["newRooms"]);                         // .Net / Unity
    System.Diagnostics.Debug.WriteLine("Group subscribed. The following rooms are now accessible: " + (List<Room>)evt.Params["newRooms"]);        // UWP
}

void OnSubscribeRoomGroupError(BaseEvent evt) {
    Console.WriteLine("Group subscription failed: " + (string)evt.Params["errorMessage"]);                          // .Net / Unity
    System.Diagnostics.Debug.WriteLine("Group subscription failed: " + (string)evt.Params["errorMessage"]);         // UWP
}
See Also