ChangeRoomNameRequest
Changes the name of a Room.
new ChangeRoomNameRequest(room, newName)
Creates a new ChangeRoomNameRequest instance. The instance must be passed to the SmartFox.send() method for the request to be executed.
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 new name doesn't match the related criteria in Zone configuration, the roomNameChangeError 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 renaming is not allowed (see the RoomSettings.permissions parameter), the request is ignored and no error is fired.
Example
This 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.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
Name | Type | Optional | Description |
---|---|---|---|
room |
|
|
The SFSRoom object corresponding to the Room whose name should be changed. |
newName |
|
|
The new name to be assigned to the Room. |