⚛️ React hooks for use with websocket-game-lobby
$ npm install websocket-game-lobby-client-hooks
const { data, connected, send } = useWebSocketGameLobbyClient({
port = 80,
keepAliveMilliseconds = 30000
});
Name | Description | Default |
---|---|---|
port |
Port to connect to WebSocket server. | 80 |
keepAliveMilliseconds |
Interval at which to ping the websocket-game-lobby server. | 30000 |
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. |
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