Skip to content

Socket.io adapter for Google Pub/Sub, allowing to setup a socket.io cluster

License

Notifications You must be signed in to change notification settings

idoshamun/socket.io-pubsub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

01b4687 · Aug 19, 2021

History

52 Commits
Apr 26, 2020
Mar 24, 2020
May 13, 2017
May 13, 2017
Mar 24, 2020
Jul 30, 2020
Jan 7, 2020
May 13, 2017
Aug 19, 2021
Sep 20, 2020

Repository files navigation

socket.io-pubsub

Build Status

How to use

const pubsub = require('@google-cloud/pubsub');
const pubsubClient = pubsub();
const io = require('socket.io')(3000);
const pubsubAdapter = require('socket.io-pubsub');
io.adapter(pubsubAdapter(pubsubClient));

By running socket.io with the socket.io-pubsub adapter you can run multiple socket.io instances in different processes or servers that can all broadcast and emit events to and from each other using Google Cloud Pub/Sub.

If you need to emit events to socket.io instances from a non-socket.io process, you should use socket.io-emitter.

API

adapter(pubsub[, opts])

pubsub is a google-cloud pubsub object.

The following options are allowed:

PubsubAdapter

The pub/sub adapter instances expose the following properties that a regular Adapter does not

  • uid
  • prefix
  • pubsub

License

Apache 2.0