new LeaveRoomRequest([room])

Creates a new LeaveRoomRequest instance. The instance must be passed to the SmartFox.send() method for the request to be executed.

This request makes the current user leave one of the Rooms he joined. Depending on the Room configuration defined upon its creation (see the RoomSettings.events setting), when the user leaves it, the following events might be fired: userExitRoom, dispatched to all the users inside the Room (including the current user then) to warn them that a user has gone away; userCountChange, dispatched to all clients which subscribed the Group to which the Room belongs, to update the count of users inside the Room.

Example

This example makes the user leave the currently joined Room and handles the related event.

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.USER_EXIT_ROOM, onUserExitRoom, this);

	// Leave the last joined Room
	sfs.send(new SFS2X.LeaveRoomRequest());
}

function onUserExitRoom(evtParams)
{
	var room = evtParams.room;
	var user = evtParams.user;

	console.log("User " + user.name + " just left Room " + room.name);
}

Parameter

Name Type Optional Description

room

 

Yes

The SFSRoom object corresponding to the Room that the current user must leave. If null, the last Room joined by the user is left.

Defaults to null.

See also
SmartFox#send
SFSEvent.USER_EXIT_ROOM
SFSEvent.USER_COUNT_CHANGE