Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/idoshamun/socket.io-pubsub
Socket.io adapter for Google Pub/Sub, allowing to setup a socket.io cluster
https://github.com/idoshamun/socket.io-pubsub
google-cloud google-cloud-pubsub high-availability socket-io websocket
Last synced: 9 days ago
JSON representation
Socket.io adapter for Google Pub/Sub, allowing to setup a socket.io cluster
- Host: GitHub
- URL: https://github.com/idoshamun/socket.io-pubsub
- Owner: idoshamun
- License: mit
- Created: 2016-06-07T19:10:09.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-17T06:51:46.000Z (over 1 year ago)
- Last Synced: 2024-04-24T13:10:45.739Z (7 months ago)
- Topics: google-cloud, google-cloud-pubsub, high-availability, socket-io, websocket
- Language: JavaScript
- Size: 490 KB
- Stars: 31
- Watchers: 5
- Forks: 17
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# socket.io-pubsub
[![Build Status](https://travis-ci.org/elegantmonkeys/socket.io-pubsub.svg?branch=master)](https://travis-ci.org/elegantmonkeys/socket.io-pubsub)
## How to use
```js
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](https://github.com/socketio/socket.io-emitter).## API
### adapter(pubsub[, opts])
`pubsub` is a [google-cloud](https://googlecloudplatform.github.io/google-cloud-node/#/docs/google-cloud) [pubsub](https://googlecloudplatform.github.io/google-cloud-node/#/docs/google-cloud/pubsub) object.
The following options are allowed:
- `key`: the topic name of the pub/sub events (`socket.io`)
- `createSubscriptionOpts`: [options for creating a subscription](https://googleapis.dev/nodejs/pubsub/latest/global.html#CreateSubscriptionRequest)### PubsubAdapter
The pub/sub adapter instances expose the following properties
that a regular `Adapter` does not- `uid`
- `prefix`
- `pubsub`## License
Apache 2.0