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 - npm Package Compare versions

Comparing version 0.3.3 to 0.4.0

2

package.json
{
"name": "@socialgorithm/game-server",
"version": "0.3.3",
"version": "0.4.0",
"description": "JS Game Server library",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

# 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.
Creates a socket server (default port 5433) 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.

@@ -11,21 +11,19 @@ ## Integrating

Start the game server:
Start the game server and supply a new game function:
```
new GameServer({ port: 3333 }, {
startGame: this.startGame,
onPlayerMessage: this.onPlayerMessage,
});
new GameServer({ name: "My Game Name" }, newGameFunction, { port: 5433 });
```
Supply functions to react to game events or player communication (`GameServerBindings`):
The new game function must accept game start parameters and can take an output channel on which to communicate with players/spectators. It must return an implementation of the `Game` interface (i.e. must implement callback to listen for player communication).
* `startGame: (options: GameOptions) => void;`
* `onPlayerMessage: (player: Player, payload: any) => void;`
```
newGameFunction(gameStartMessage: GameStartMessage, outputChannel: GameOutputChannel): Game {
debug("Started new game");
return new MyGame(gameStartMessage.players, outputChannel);
}
```
Call functions when you want to communicate with players or broadcast game state to spectators (e.g. UIs):
In your game, you can then use `GameOutputChannel` to communicate with players or spectators (e.g. the Tournament Server).
* `sendPlayerMessage: (player: Player, payload: any) => void;`
* `sendGameMessage: (messageType: MessageType, payload: any) => void;`
### Example

@@ -41,6 +39,6 @@

To publish to NPM, make sure you've incremented the version number and run:
To publish to NPM, make sure you've incremented the version number (e.g. `npm version patch`) and run:
```
yarn
npm publish
```
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