Click or drag to resize

ChangeRoomPasswordStateRequest Class

Changes the password of a Room.
Inheritance Hierarchy
SystemObject
  BaseRequest
    Sfs2X.RequestsChangeRoomPasswordStateRequest

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

The ChangeRoomPasswordStateRequest type exposes the following members.

Constructors
  NameDescription
Public methodChangeRoomPasswordStateRequest
Creates a new ChangeRoomPasswordStateRequest instance.
Top
Remarks
This request not only changes the password of a Room, but also its "password state", which indicates if the Room is password protected or not.

If the operation is successful, the ROOM_PASSWORD_STATE_CHANGE event is dispatched to all the users who subscribed the Group to which the target Room belongs, including the requester user himself. If the user is not the creator (owner) of the Room, the ROOM_PASSWORD_STATE_CHANGE_ERROR event is fired. An administrator or moderator can override this constrain (he is not requested to be the Room's owner).
If the Room was configured so that password change is not allowed (see the RoomSettings.Permissions parameter), the request is ignored and no error is fired.

Examples
The following example changes the password of an existing Room:
void SomeMethod() {
    sfs.AddEventListener(SFSEvent.ROOM_PASSWORD_STATE_CHANGE, OnRoomPasswordStateChange);
    sfs.AddEventListener(SFSEvent.ROOM_PASSWORD_STATE_CHANGE_ERROR, OnRoomPasswordStateChangeError);

    Room theRoom = sfs.GetRoomByName("Gonzo's Room");
    sfs.Send( new ChangeRoomPasswordStateRequest(theRoom, "mammamia") );
}

void OnRoomPasswordStateChange(BaseEvent evt) {
    Room theRoom = (Room)evt.Params["room"];
    Console.WriteLine("The password of Room " + theRoom.Name + " was changed successfully");                        // .Net / Unity
    System.Diagnostics.Debug.WriteLine("The password of Room " + theRoom.Name + " was changed successfully");       // UWP
}

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