@boardgame.io/redis-pubsub
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

@boardgame.io/redis-pubsub

This package provides a Redis pub/sub adapter for boardgame.io.

Installation

npm install @boardgame.io/redis-pubsub

Requirements

Requires redis npm library 3.1.2 or greater (docs), and boardgame.io version 0.47.0 or greater (docs). Using a database adaptor (i.e. postgres) that stores and shares the state across servers is also required to properly horizontally scale them.

Usage

import { RedisPubSub } from 'bgio-redis-pubsub'
import { Server, Origins, SocketIO } from 'boardgame.io/server';
import MyGame from './src/MyGame';
import redis from 'redis';
import { PostgresStore } from 'bgio-postgres';

const redisConfig = { host: '192.168.8.50' };
const pubClient = redis.createClient(redisConfig);
const subClient = pubClient.duplicate();
const server = Server({
  games: [MyGame],
  db: new PostgresStore('vdf@192.168.8.50/vdf'),
  origins: [Origins.LOCALHOST],
  transport: new SocketIO({
    pubSub: new RedisPubSub(pubClient, subClient),
  }),
});
server.run(8000);

Dependents (0)

Package Sidebar

Install

npm i @boardgame.io/redis-pubsub

Weekly Downloads

10

Version

0.0.1

License

MIT

Unpacked Size

8.25 kB

Total Files

9

Last publish

Collaborators

  • nicolodavis
  • jasonharrison
  • flamecoals
  • delucis