Module: socket

Methods

(static) attachChatCallbackFns(callbackFns)

Attaches functions to websocket instance to orchestrate chat behavior; avoids cyclic use of import statements
Parameters:
Name Type Description
callbackFns Record.<string, function()> object literal map of functions
Source:

(static) attachGameCallbackFns(callbackFns)

Attaches functions to WebSocket instance to orchestrate Versus gameplay behavior; avoids cyclic use of import statements
Parameters:
Name Type Description
callbackFns Record.<string, function()> object literal map of functions
Source:

(static) initializeWebSocket()

Initializes behavior of WebSocket; connects to backend WS server and relays profile
Source:

(static) joinInstance(gameCode)

Attempts to move client to a new game instance associated to gameCode
Parameters:
Name Type Description
gameCode number four digit code corresponding to an existing game instance
Source:

(static) selectCard(selectedCard)

Tells server which card the client selected
Parameters:
Name Type Description
selectedCard Types.Card card selected by user from list of remaining cards
Source:

(static) sendChatMessage(messageContents)

Sends chat message server-side to be redistributed to clients, implicitly associated to user profile of sender
Parameters:
Name Type Description
messageContents string text content of message to be displayed
Source:

(static) sendInitializationRequest(previousUUIDopt)

Asks backend to add client to a new lobby, or restore to a previous lobby if possible
Parameters:
Name Type Attributes Description
previousUUID Types.UUID <optional>
any previous UUID to client, used for restoration
Source:

(static) sendProfile()

Updates profile information on backend by creating and sending current profile information
Source:

(static) startGame()

Attempts to start game instance server-side (implicitly starts first round)
Source:

(inner) handleMessage(message)

Handles and redirects incoming messages to appropriate functions
Parameters:
Name Type Description
message MessageEvent incoming message from server
Source:

(inner) handleWebSocketClose()

Source:

(inner) handleWebSocketOpen()

Source:

(inner) sendMessage(message)

Sends parsed message object directly to the server
Parameters:
Name Type Description
message Types.ClientToServerMessage action/info message pair to send
Source: