Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@socialgorithm/game-server

Package Overview
Dependencies
Maintainers
2
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@socialgorithm/game-server

JS Game Server library

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
2
Weekly downloads
 
Created
Source

JavaScript Game Server

Creates a socket server (default port 3333) that serves games. To use this server, you provide functions that will be called on game or player actions, and call functions to communicate with players or to broadcast game state to spectators.

Integrating

Install the dependency:

npm install @socialgorithm/game-server

Start the game server:

  new GameServer({ port: 3333 }, {
    startGame: this.startGame,
    onPlayerMessage: this.onPlayerMessage,
  });

Supply functions to react to game events or player communication (GameServerBindings):

  • startGame: (options: GameOptions) => void;
  • onPlayerMessage: (player: Player, payload: any) => void;

Call functions when you want to communicate with players or broadcast game state to spectators (e.g. UIs):

  • sendPlayerMessage: (player: Player, payload: any) => void;
  • sendGameMessage: (messageType: MessageType, payload: any) => void;

Example

See tic-tac-toe for an example of integration.

Contributing

The rest of this guide is for contributors.

Publishing to NPM

To publish to NPM, make sure you've incremented the version number and run:

yarn 

Keywords

FAQs

Package last updated on 06 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc