@brajkowski/connect4-multiplayer-common
v1.0.1
Published
This library provides shared objects used by both the connect 4 multiplayer client and server.
Downloads
42
Maintainers
Readme
Connect 4 Multiplayer: Common
This library defines the packet interfaces and actions used by both the connect 4 multiplayer client and server.
Installation
Using npm:
$ npm i --save @brajkowski/connect4-multiplayer-common
Usage
Packet Interfaces
server => client
packets adhere to theServerPacket
interfaceclient => server
packets adhere to theClientPacket
interface
Action Values and Meaning
Both the client and the server send an action value in their respective packet payloads in order to trigger, and respond to, events:
| ServerAction Values | Description | | -------------------------------------------------------- | --------------------------------------------------------- | | 0 | The client action is not allowed. | | 1 | An opponent has joined the session. | | 2 | An opponent has placed a chip. | | 3 | A new session has been created. | | 4 | The client has joined a session. | | 5 | The session the client is trying to reach does not exist. | | 6 | The opponent has quit (graceful exit). | | 7 | The game has finished and a new one is starting. | | 8 | The session has ended (due to inactivity). |
| ClientAction Values | Description | | -------------------------------------------------------- | -------------------------------------------------------- | | 0 | The client is requesting a new session to be created. | | 1 | The client is requesting to join an existing session. | | 2 | The client is requesting to place a chip at a location. | | 3 | The client is gracefully quitting / leaving the session. |
Building from Source
Using npm:
$ npm run build
will produce the compiled library under /dist
.