1.0.1 • Published 4 years ago

@brajkowski/connect4-multiplayer-common v1.0.1

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

Connect 4 Multiplayer: Common

Build npm:latest npm:beta semantic-release

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 the ServerPacket interface
  • client => server packets adhere to the ClientPacket 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 ValuesDescription
0The client action is not allowed.
1An opponent has joined the session.
2An opponent has placed a chip.
3A new session has been created.
4The client has joined a session.
5The session the client is trying to reach does not exist.
6The opponent has quit (graceful exit).
7The game has finished and a new one is starting.
8The session has ended (due to inactivity).
ClientAction ValuesDescription
0The client is requesting a new session to be created.
1The client is requesting to join an existing session.
2The client is requesting to place a chip at a location.
3The client is gracefully quitting / leaving the session.

Building from Source

Using npm:

$ npm run build

will produce the compiled library under /dist.