websocket-game-lobby-client-hooks
TypeScript icon, indicating that this package has built-in type declarations

1.5.6 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i websocket-game-lobby-client-hooks

Weekly Downloads

3

Version

1.5.6

License

MIT

Unpacked Size

7.54 kB

Total Files

7

Last publish

Collaborators

  • neogeek