# socket.io-pubsub-3

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

Latest version **3.1.5** (published 2021-07-19) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install socket.io-pubsub-3
pnpm add socket.io-pubsub-3
yarn add socket.io-pubsub-3
bun add socket.io-pubsub-3
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.5 |
| Published | 2021-07-19 |
| First published | 2021-05-18 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.13.0 |
| Dependencies | 5 |
| Unpacked size | 18 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 31 |
| Maintainers | npsedhain |
| Keywords | socket.io, gcp, gcloud, pubsub, adapter, cluster, websocket |

## Links

- npm: https://www.npmjs.com/package/socket.io-pubsub-3
- Repository: https://github.com/elegantmonkeys/socket.io-pubsub
- Homepage: https://github.com/elegantmonkeys/socket.io-pubsub#readme
- Issues: https://github.com/elegantmonkeys/socket.io-pubsub/issues
- npm.io page: https://npm.io/package/socket.io-pubsub-3

## Dependencies (5)

- [acorn](https://npm.io/package/acorn.md) ^6.1.1
- [async](https://npm.io/package/async.md) ^2.6.1
- [debug](https://npm.io/package/debug.md) ^3.1.0
- [shortid](https://npm.io/package/shortid.md) ^2.2.8
- [socket.io-adapter](https://npm.io/package/socket.io-adapter.md) ^2.2.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 3.1.5 (latest) — 2021-07-19
- 3.1.4 — 2021-07-15
- 3.1.3 — 2021-06-21
- 3.1.2 — 2021-06-21
- 3.1.1 — 2021-06-21
- 3.1.0 — 2021-06-21
- 3.0.0 — 2021-05-18

## 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

---
_Source: https://npm.io/package/socket.io-pubsub-3 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
