joinRoom()
Availability:
SmartFoxServer Lite / Basic / Pro
Usage:
smartFox.joinRoom(roomId <integer>, password <String>, isSpectator <true/false>, dontLeave <true/false>, oldRoom <integer>)
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 flag) If true joins the user as a spectator in a game room | |
dontLeave | (optional 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 |
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()