Skip to content

⚛️ React hooks for use with websocket-game-lobby

License

Notifications You must be signed in to change notification settings

neogeek/websocket-game-lobby-client-hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

websocket-game-lobby-client-hooks

⚛️ React hooks for use with websocket-game-lobby

NPM Version

Install

$ npm install websocket-game-lobby-client-hooks

API

useWebSocketGameLobbyClient

const { data, connected, send } = useWebSocketGameLobbyClient({
    port = 80,
    keepAliveMilliseconds = 30000
});

Options

Name Description Default
port Port to connect to WebSocket server. 80
keepAliveMilliseconds Interval at which to ping the websocket-game-lobby server. 30000

send(type, data);

Type
Name Description
create Create a new game.
join Join existing game with game code.
leave Leave current game.
start Start current game.
end End current game.
Examples
send('create'); // Create new game
send('join', { gameCode: 'ABCD' }); // Join game with game code
send('leave'); // Leave current game
send('start'); // Start current game
send('end'); // End current game