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 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.


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 =;
	var user = evtParams.user;

	console.log("User " + + " just left Room " +;


Name Type Optional Description




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