joinRoom()

Availability:

Flash Player 6.0
SmartFoxServer Lite / Basic / Pro

Usage:

smartFox.joinRoom(roomId, password, isSpectator, dontLeave, oldRoom)

Description:

Join a user in a room.

Parameters:

roomId   the id or the name of the room you want to join (you can both pass the name of the room or it's numeric id)
password   the password for the room (needed if the room is password protected)
isSpectator   (optional booelan flag) If true joins the user as a spectator in a game room
dontLeave   (optional boolean flag) If true the user will not leave the room where he/shw is currently in
oldRoom   (optional) the roomId of the room to leave

NOTE: The optional paramaters enable the developer to use the advanced multi-room feature of SmartFoxServer which allows a user to be logged in two or more rooms at the same time. If you don't need this feature just use the first two arguments. (see the examples below)

Returns:

Fires the onJoinRoom event

Example:

Example #1
The user requests to join a number with id = 10 (by default SmartFoxServer will disconnect him from the previous room)

smartFox.joinRoom(10)

Example #2
The user requests to join a number with id = 12 and password = "mypassword"
(by default SmartFoxServer will disconnect him from the previous room)

smartFox.joinRoom(12, "mypassword")

Example #3
The user requests to join the room with id = 15 and passes the dontLeave flag = true.
This will join the user in the new room while keeping him in the old room as well.

smartFox.joinRoom(15, "", false, true)

See also:

onJoinRoomError()