socket.io-redis
Advanced tools
Comparing version 6.0.0 to 6.0.1
@@ -0,1 +1,11 @@ | ||
## [6.0.1](https://github.com/socketio/socket.io-redis/compare/6.0.0...6.0.1) (2020-11-14) | ||
### Bug Fixes | ||
* **typings:** properly expose the createAdapter method ([0d2d69c](https://github.com/socketio/socket.io-redis/commit/0d2d69cc78aa3418a7b5a6231a13ea4028dd74a3)) | ||
* fix broadcasting ([#361](https://github.com/socketio/socket.io-redis/issues/361)) ([3334d99](https://github.com/socketio/socket.io-redis/commit/3334d99e1b6e2f80485c73133381a18798b24bc0)) | ||
# [6.0.0](https://github.com/socketio/socket.io-redis/compare/5.4.0...6.0.0) (2020-11-12) | ||
@@ -2,0 +12,0 @@ |
import { Adapter, BroadcastOptions, Room, SocketId } from "socket.io-adapter"; | ||
export interface RedisAdapterOptions { | ||
/** | ||
* the name of the key to pub/sub events on as prefix | ||
* @default socket.io | ||
*/ | ||
key: string; | ||
/** | ||
* the redis client to publish events on | ||
*/ | ||
pubClient: any; | ||
/** | ||
* the redis client to subscribe to events on | ||
*/ | ||
subClient: any; | ||
/** | ||
* after this timeout the adapter will stop waiting from responses to request | ||
* @default 5000 | ||
*/ | ||
requestsTimeout: number; | ||
@@ -18,2 +32,3 @@ } | ||
export declare function createAdapter(uri: string, opts?: Partial<RedisAdapterOptions>): any; | ||
export declare function createAdapter(opts: Partial<RedisAdapterOptions>): any; | ||
export declare class RedisAdapter extends Adapter { | ||
@@ -20,0 +35,0 @@ readonly uid: any; |
@@ -9,2 +9,3 @@ "use strict"; | ||
const debug = require("debug")("socket.io-redis"); | ||
module.exports = exports = createAdapter; | ||
/** | ||
@@ -256,3 +257,3 @@ * Request types, for messages between nodes | ||
rooms: [...opts.rooms], | ||
except: [...opts.except], | ||
except: [...new Set(opts.except)], | ||
flags: opts.flags, | ||
@@ -468,2 +469,1 @@ }; | ||
exports.RedisAdapter = RedisAdapter; | ||
module.exports = createAdapter; |
{ | ||
"name": "socket.io-redis", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -9,2 +9,5 @@ # socket.io-redis | ||
- [How to use](#how-to-use) | ||
- [CommonJS](#commonjs) | ||
- [ES6 module](#es6-modules) | ||
- [TypeScript](#typescript) | ||
- [Compatibility table](#compatibility-table) | ||
@@ -30,2 +33,4 @@ - [API](#api) | ||
### CommonJS | ||
```js | ||
@@ -37,4 +42,29 @@ const io = require('socket.io')(3000); | ||
By running socket.io with the `socket.io-redis` adapter you can run | ||
multiple socket.io instances in different processes or servers that can | ||
### ES6 modules | ||
```js | ||
import { Server } from 'socket.io'; | ||
import redisAdapter from 'socket.io-redis'; | ||
const io = new Server(3000); | ||
io.adapter(redisAdapter({ host: 'localhost', port: 6379 })); | ||
``` | ||
### TypeScript | ||
```ts | ||
// npm i -D @types/redis | ||
import { Server } from 'socket.io'; | ||
import { createAdapter } from 'socket.io-redis'; | ||
import { RedisClient } from 'redis'; | ||
const io = new Server(8080); | ||
const pubClient = new RedisClient({ host: 'localhost', port: 6379 }); | ||
const subClient = pubClient.duplicate(); | ||
io.adapter(createAdapter({ pubClient, subClient })); | ||
``` | ||
By running Socket.IO with the `socket.io-redis` 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. | ||
@@ -191,5 +221,5 @@ | ||
const redisAdapter = require('socket.io-redis'); | ||
const pub = redis.createClient(port, host, { auth_pass: "pwd" }); | ||
const sub = redis.createClient(port, host, { auth_pass: "pwd" }); | ||
io.adapter(redisAdapter({ pubClient: pub, subClient: sub })); | ||
const pubClient = redis.createClient(port, host, { auth_pass: "pwd" }); | ||
const subClient = pubClient.duplicate(); | ||
io.adapter(redisAdapter({ pubClient, subClient })); | ||
``` | ||
@@ -196,0 +226,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
32968
587
296
0