JoinRoomRequest

Joins the User in a Room.


If the join operation is successful, the User receives a SFSEvent.ROOM_JOIN event; otherwise the SFSEvent.ROOM_JOIN_ERROR event is fired. This usually happens when the Room is full, or the password is wrong in case of password protected Rooms.

Depending on the Room configuration (set when it was created - see the RoomSettings#events setting), when the User joins the Room, the following events may be fired: SFSEvent.USER_ENTER_ROOM, dispatched to the other Users inside the Room to warn them that a new User has arrived; SFSEvent.USER_COUNT_CHANGE, dispatched to all clients which subscribed the Group to which the Room belongs, to update the count of Users inside the Room.

Constructor

new JoinRoomRequest(targetRoom, passwordopt, roomIdToLeaveopt, asSpectatoropt)

Creates a new instance of the JoinRoomRequest class.
Pass the instance to the SmartFox#send method to validate and execute the request.
Parameters:
NameTypeAttributesDefaultDescription
targetRoomnumber | string | SFSRoomThe id or name or SFSRoom object of the Room to be joined.
passwordstring<optional>
nullThe password of the Room, in case it is password protected.
roomIdToLeavenumber<optional>
nullThe id of a previously joined Room that the User should leave when joining the new Room. By default, the last joined Room is left; if a negative number is passed, no previous Room is left.
asSpectatorboolean<optional>
falseIf true, Room is joined as a Spectator (in Game Rooms only).