Class SFS2X.Requests.System.ChangeRoomPasswordStateRequest

Changes the password of a Room.

Class Summary
Constructor Attributes Constructor Name and Description
Creates a new ChangeRoomPasswordStateRequest instance.

Class Detail

SFS2X.Requests.System.ChangeRoomPasswordStateRequest(room, newPass)
Creates a new ChangeRoomPasswordStateRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.

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 roomPasswordStateChange 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, or if the Room was configured so that password changing is not allowed (see the RoomSettings.permissions parameter), the roomPasswordStateChangeError event if fired. An administrator or moderator can override the first constrain (he is not requested to be the Room's owner).

The following example changes the password of an existing Room:

function someMethod()
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_PASSWORD_STATE_CHANGE, onRoomPasswordStateChanged, this);
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_PASSWORD_STATE_CHANGE_ERROR, onRoomPasswordStateChangeError, this);
	var theRoom = sfs.getRoomByName("Gonzo's Room");
	sfs.send(new SFS2X.Requests.System.ChangeRoomPasswordStateRequest(theRoom, "mammamia"));

function onRoomPasswordStateChanged(evtParams)
	trace("The password of Room " + + " was changed successfully");

function onRoomPasswordStateChangeError(evtParams)
	trace("Room password change failed: " + evtParams.errorMessage);
{SFSRoom} room
The SFSRoom object corresponding to the Room whose password should be changed.
{String} newPass
The new password to be assigned to the Room; an empty string or the null value can be passed to remove the Room's password.
See also: