Class SFS2X.Requests.System.ChangeRoomNameRequest

Changes the name of a Room.

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

Class Detail

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

This request changes the name of a Room. If the renaming operation is successful, the roomNameChange event is dispatched to all the users who subscribed the Group to which the target Room belongs, including the user who renamed it. If the user is not the creator (owner) of the Room, or if the Room was configured so that renaming is not allowed (see the RoomSettings.permissions parameter), the roomNameChangeError 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 renames an existing Room:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_NAME_CHANGE, onRoomNameChanged, this);
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_NAME_CHANGE_ERROR, onRoomNameChangeError, this);
	
	var theRoom = sfs.getRoomByName("Gonzo's Room");
	sfs.send(new SFS2X.Requests.System.ChangeRoomNameRequest(theRoom, "Gonzo The Great's Room"));
}

function onRoomNameChanged(evtParams)
{
	console.log("Room " + evtParams.oldName + " was successfully renamed to " + evtParams.room.name);
}

function onRoomNameChangeError(evtParams)
{
	console.log("Room name change failed: " + evtParams.errorMessage);
}
Parameters:
{SFSRoom} room
The SFSRoom object corresponding to the Room whose name should be changed.
{String} newName
The new name to be assigned to the Room.
See also:
SFS2X.SmartFox#send
SFS2X.Requests.RoomSettings#permissions
SFS2X.SFSEvent.ROOM_NAME_CHANGE
SFS2X.SFSEvent.ROOM_NAME_CHANGE_ERROR