Class: Lobby

Lobby(MAX_ROOMS_PER_LOBBY)

Class representing a Lobby. A Lobby is where all the rooms and the players' connections are stored Think of a Lobby as the place where all the players hangout before they are matched to a room

Constructor

new Lobby(MAX_ROOMS_PER_LOBBY)

Parameters:
Name Type Description
MAX_ROOMS_PER_LOBBY integer

maximum rooms per lobby based on the number of rooms members per room & the app instance flavor (server performance)

Source:

Methods

addPlayer(playerKey, connection)

Parameters:
Name Type Description
playerKey string

unique identifier of the session using the |Sec-WebSocket-Key| header

connection ws

websocket connection

Source:

addRoom(room)

Parameters:
Name Type Description
room Room

room object, representing the room to be added

Source:

getPlayerConnection(playerId)

Parameters:
Name Type Description
playerId string

unique player id assigned once the connection is established using uuid package

Source:

getRoomById(roomId)

Parameters:
Name Type Description
roomId string

the unique room id of the room

Source:

markRoomAsFull(room)

Parameters:
Name Type Description
room Room

room object, representing the room to be marked full

Source:

notifyLobbyMembers(Event)

Parameters:
Name Type Description
Event Event

event object, representing the event to be sent to Lobby members

Source:

removePlayer(playerId)

Parameters:
Name Type Description
playerId string

unique player id assigned once the connection is established using uuid package

Source:

removeRoom(roomId)

Parameters:
Name Type Description
roomId string

the unique room id of the room to be removed

Source:

udpConnectionExists(udpClient)

Parameters:
Name Type Description
udpClient UDPClient

UDPClient object

Source:

updateRoomUDPClientsMap(roomId, udpClient)

Parameters:
Name Type Description
roomId string

the unique room id of the room

udpClient UDPClient

UDPClient Object, representing the udp connection to be added to the udpClientsMap

Source: