1.1.5 • Published 4 years ago

lobby-client v1.1.5

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

lobby-client

A small wrapper around websockets that handles realtime connections to online lobbies. The lobby-server is needed to manage the pool of lobbies. When instantiating the LobbyClient below, the address and port that the lobby-server is listening on must be specified.

Installation

npm install lobby-client

Usage

import LobbyClient from "lobby-client";

const lobby = LobbyClient(
  "https://somelobbyserver.com:3000", // specify address and port of the lobby server
  "Chess Game 123", // Join lobby with this name or create one if it did not exist
  (json) => {
    // callback to specify what to do when other clients send json
    movePiece(json);
  }
);

// Later, we can send any valid json to other clients in the lobby (objects, strings)
// We send our client's chess move in this example
lobby.send({ startX: 0, startY: 1, endX: 0, endY: 3 });

// Disconnects explicitly from the lobby
// Websockets are also closed after a long period of inactivity, which is handled by socket.io
lobby.leave();

Contributing

Pull requests are welcome. An issue can be opened for larger changes.

License

MIT

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago