@mickl/socket.io-nats-adapter
v2.0.1
Published
Socket.io 3.x/4.x adapter for NATS
Downloads
1,162
Readme
socket.io-adapter-nats
Socket.IO NATS adapter for:
- Socket.IO 4.x, but should also work with 2.x and 3.x
- NATS.js 2.x, for NATS.js 1.x use
@^1.0.0
of this package
For just emitting there is also socket.io-nats-emitter
Status
- ✅ Emit
- ✅ Room(s)
- ✅ Namespace
- ✅ Local flag
- ❌ Get all rooms across several nodes
- ❌ Get all sockets in the same room across several nodes
If you have any issues or feature requests please create a pull request.
This project has used socket.io-redis-adapter as a reference but modernized most of the code (e.g. using async and promises and wrote test's in TypeScript, too).
How to use
yarn add socket.io nats @mickl/socket.io-nats-adapter
import { Server } from 'socket.io';
import { connect } from 'nats';
import { createAdapter } from '@mickl/socket.io-nats-adapter';
const io = new Server(3000);
const connection = await connect();
io.adapter(createAdapter(connection));
License
MIT