{"_id":"@socket.io/redis-streams-emitter","_rev":"2-e65103e2d35a57198046b8df5d5b7ce0","name":"@socket.io/redis-streams-emitter","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@socket.io/redis-streams-emitter","version":"0.1.0","keywords":["socket.io","redis","redis-streams","emitter"],"license":"MIT","_id":"@socket.io/redis-streams-emitter@0.1.0","maintainers":[{"name":"darrachequesne","email":"damien.arrachequesne@gmail.com"}],"homepage":"https://github.com/socketio/socket.io/tree/main/packages/socket.io-redis-streams-emitter#readme","bugs":{"url":"https://github.com/socketio/socket.io/issues"},"dist":{"shasum":"19b5296a1323d7c1227424daf397b019fc303225","tarball":"https://registry.npmjs.org/@socket.io/redis-streams-emitter/-/redis-streams-emitter-0.1.0.tgz","fileCount":9,"integrity":"sha512-34+aVbYwLYZKxnoBMTMYRMTrWgDPGJXryXbe5xvY+a54/EKUHQP+qcC5V180lhMusIx/Nq9PktGk326WK6jTWA==","signatures":[{"sig":"MEYCIQDiYadMN3jE9bt7nyywqRde3QlGZYn3SCg12pOW8hegbwIhAIc0Dz128rAhm+MvtR9hBcXtIPj6P4wnhqz/pULRVUbB","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@socket.io%2fredis-streams-emitter@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":29949},"main":"./dist/index.js","types":"./dist/index.d.ts","gitHead":"599001d213f0090b81a9937ab678597ec6ae2572","scripts":{"test":"npm run format:check && npm run compile && npm run test:redis-standalone && npm run test:ioredis-standalone","compile":"rimraf ./dist && tsc","prepack":"npm run compile","format:fix":"prettier --parser typescript --write 'lib/**/*.ts' 'test/**/*.ts'","format:check":"prettier --parser typescript --check 'lib/**/*.ts' 'test/**/*.ts'","test:redis-cluster":"REDIS_CLUSTER=1 mocha --import=tsx test/**/*.ts","test:ioredis-cluster":"REDIS_LIB=ioredis REDIS_CLUSTER=1 mocha --import=tsx test/**/*.ts","test:redis-standalone":"nyc mocha --import=tsx test/**/*.ts","test:valkey-standalone":"VALKEY=1 mocha --import=tsx test/**/*.ts","test:ioredis-standalone":"REDIS_LIB=ioredis mocha --import=tsx test/**/*.ts"},"_npmUser":{"name":"darrachequesne","email":"damien.arrachequesne@gmail.com"},"repository":{"url":"git+https://github.com/socketio/socket.io.git","type":"git"},"_npmVersion":"10.8.2","description":"The Socket.IO Redis streams emitter, allowing to communicate with a group of Socket.IO servers from another Node.js process","directories":{},"_nodeVersion":"20.19.5","dependencies":{"debug":"~4.4.1","@msgpack/msgpack":"~2.8.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/redis-streams-emitter_0.1.0_1762449976905_0.6389285626813419","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@socket.io/redis-streams-emitter","version":"0.1.1","description":"The Socket.IO Redis streams emitter, allowing to communicate with a group of Socket.IO servers from another Node.js process","license":"MIT","homepage":"https://github.com/socketio/socket.io/tree/main/packages/socket.io-redis-streams-emitter#readme","repository":{"type":"git","url":"git+https://github.com/socketio/socket.io.git"},"main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"compile":"rimraf ./dist && tsc","format:check":"prettier --parser typescript --check 'lib/**/*.ts' 'test/**/*.ts'","format:fix":"prettier --parser typescript --write 'lib/**/*.ts' 'test/**/*.ts'","prepack":"npm run compile","test":"npm run format:check && npm run compile && npm run test:redis-standalone && npm run test:ioredis-standalone","test:redis-standalone":"nyc mocha --import=tsx test/**/*.ts","test:redis-cluster":"REDIS_CLUSTER=1 mocha --import=tsx test/**/*.ts","test:ioredis-standalone":"REDIS_LIB=ioredis mocha --import=tsx test/**/*.ts","test:ioredis-cluster":"REDIS_LIB=ioredis REDIS_CLUSTER=1 mocha --import=tsx test/**/*.ts","test:valkey-standalone":"VALKEY=1 mocha --import=tsx test/**/*.ts"},"dependencies":{"@msgpack/msgpack":"~2.8.0","debug":"~4.4.1"},"keywords":["socket.io","redis","redis-streams","emitter"],"_id":"@socket.io/redis-streams-emitter@0.1.1","gitHead":"54743633ffa7bd595cc759d4affc49121fedaeb4","bugs":{"url":"https://github.com/socketio/socket.io/issues"},"_nodeVersion":"20.19.5","_npmVersion":"10.8.2","dist":{"integrity":"sha512-7NS8ae986RMhwQvXzww3bzlz0OFE7olM6bZRXHWytpc/ZadR7Tv1iYnyUsJ7t4rrQ/455NMcFzmYZ6ir+AySNA==","shasum":"9271888d2fe6a9f8c8822c8e620e3d580cac100b","tarball":"https://registry.npmjs.org/@socket.io/redis-streams-emitter/-/redis-streams-emitter-0.1.1.tgz","fileCount":11,"unpackedSize":31192,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@socket.io%2fredis-streams-emitter@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCx9Dp10BCFW16NNZ0lKWs19+upndrVdu5/pDb1BbBdwgIgZ2YBQ/cSRkhcyuTA8Ofx4bYtV3Qm5zNLKBqZBMmJf2k="}]},"_npmUser":{"name":"darrachequesne","email":"damien.arrachequesne@gmail.com"},"directories":{},"maintainers":[{"name":"darrachequesne","email":"damien.arrachequesne@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/redis-streams-emitter_0.1.1_1762508169098_0.19406310790830394"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-06T17:26:16.783Z","modified":"2025-11-07T09:36:09.753Z","0.1.0":"2025-11-06T17:26:17.096Z","0.1.1":"2025-11-07T09:36:09.272Z"},"bugs":{"url":"https://github.com/socketio/socket.io/issues"},"license":"MIT","homepage":"https://github.com/socketio/socket.io/tree/main/packages/socket.io-redis-streams-emitter#readme","keywords":["socket.io","redis","redis-streams","emitter"],"repository":{"type":"git","url":"git+https://github.com/socketio/socket.io.git"},"description":"The Socket.IO Redis streams emitter, allowing to communicate with a group of Socket.IO servers from another Node.js process","maintainers":[{"name":"darrachequesne","email":"damien.arrachequesne@gmail.com"}],"readme":"# Socket.IO Redis Streams emitter\n\nThe `@socket.io/redis-streams-emitter` package allows you to easily communicate with a group of Socket.IO servers from another Node.js process (server-side).\n\nIt must be used in conjunction with [`@socket.io/redis-streams-adapter`](https://github.com/socketio/socket.io-redis-streams-adapter).\n\n**Table of contents**\n\n<!-- TOC -->\n  * [Installation](#installation)\n  * [Usage](#usage)\n    * [With the `redis` package](#with-the-redis-package)\n    * [With the `redis` package and a Redis cluster](#with-the-redis-package-and-a-redis-cluster)\n    * [With the `ioredis` package](#with-the-ioredis-package)\n    * [With the `ioredis` package and a Redis cluster](#with-the-ioredis-package-and-a-redis-cluster)\n  * [Options](#options)\n  * [API](#api)\n    * [`Emitter(redisClient[, nsp][, opts])`](#emitterredisclient-nsp-opts)\n    * [`Emitter#to(room:string):BroadcastOperator`](#emittertoroomstringbroadcastoperator)\n    * [`Emitter#in(room:string):BroadcastOperator`](#emitterinroomstringbroadcastoperator)\n    * [`Emitter#except(room:string):BroadcastOperator`](#emitterexceptroomstringbroadcastoperator)\n    * [`Emitter#of(namespace:string):Emitter`](#emitterofnamespacestringemitter)\n    * [`Emitter#socketsJoin(rooms:string|string[])`](#emittersocketsjoinroomsstringstring)\n    * [`Emitter#socketsLeave(rooms:string|string[])`](#emittersocketsleaveroomsstringstring)\n    * [`Emitter#disconnectSockets(close:boolean)`](#emitterdisconnectsocketscloseboolean)\n    * [`Emitter#serverSideEmit(ev:string[,...args:any[]])`](#emitterserversideemitevstringargsany)\n  * [License](#license)\n<!-- TOC -->\n\n## Installation\n\n```\nnpm install @socket.io/redis-streams-emitter redis\n```\n\n## Usage\n\n### With the `redis` package\n\n```js\nimport { createClient } from \"redis\";\nimport { Emitter } from \"@socket.io/redis-streams-emitter\";\n\nconst redisClient = createClient({\n  url: \"redis://localhost:6379\"\n});\n\nawait redisClient.connect();\n\nconst io = new Emitter(redisClient);\n\nsetInterval(() => {\n  io.emit(\"ping\", new Date());\n}, 1000);\n```\n\n### With the `redis` package and a Redis cluster\n\n```js\nimport { createCluster } from \"redis\";\nimport { Emitter } from \"@socket.io/redis-streams-emitter\";\n\nconst redisClient = createCluster({\n  rootNodes: [\n    {\n      url: \"redis://localhost:7000\",\n    },\n    {\n      url: \"redis://localhost:7001\",\n    },\n    {\n      url: \"redis://localhost:7002\",\n    },\n  ],\n});\n\nawait redisClient.connect();\n\nconst io = new Emitter(redisClient);\n\nsetInterval(() => {\n  io.emit(\"ping\", new Date());\n}, 1000);\n```\n\n### With the `ioredis` package\n\n```js\nimport { Redis } from \"ioredis\";\nimport { Emitter } from \"@socket.io/redis-streams-emitter\";\n\nconst redisClient = new Redis();\n\nconst io = new Emitter(redisClient);\n\nsetInterval(() => {\n  io.emit(\"ping\", new Date());\n}, 1000);\n```\n\n### With the `ioredis` package and a Redis cluster\n\n```js\nimport { Cluster } from \"ioredis\";\nimport { Emitter } from \"@socket.io/redis-streams-emitter\";\n\nconst redisClient = new Cluster([\n  {\n    host: \"localhost\",\n    port: 7000,\n  },\n  {\n    host: \"localhost\",\n    port: 7001,\n  },\n  {\n    host: \"localhost\",\n    port: 7002,\n  },\n]);\n\nconst io = new Emitter(redisClient);\n\nsetInterval(() => {\n  io.emit(\"ping\", new Date());\n}, 1000);\n```\n\n## Options\n\n| Name         | Description                                                        | Default value |\n|--------------|--------------------------------------------------------------------|---------------|\n| `streamName` | The name of the Redis stream.                                      | `socket.io`   |\n| `maxLen`     | The maximum size of the stream. Almost exact trimming (~) is used. | `10_000`      |\n\n## API\n\n### `Emitter(redisClient[, nsp][, opts])`\n\n```js\nconst io = new Emitter(redisClient);\n```\n\n### `Emitter#to(room:string):BroadcastOperator`\n### `Emitter#in(room:string):BroadcastOperator`\n\nSpecifies a specific `room` that you want to emit to.\n\n```js\nio.to(\"room1\").emit(\"hello\");\n```\n\n### `Emitter#except(room:string):BroadcastOperator`\n\nSpecifies a specific `room` that you want to exclude from broadcasting.\n\n```js\nio.except(\"room2\").emit(\"hello\");\n```\n\n### `Emitter#of(namespace:string):Emitter`\n\nSpecifies a specific namespace that you want to emit to.\n\n```js\nconst customNamespace = io.of(\"/custom\");\n\ncustomNamespace.emit(\"hello\");\n```\n\n### `Emitter#socketsJoin(rooms:string|string[])`\n\nMakes the matching socket instances join the specified rooms:\n\n```js\n// make all Socket instances join the \"room1\" room\nio.socketsJoin(\"room1\");\n\n// make all Socket instances of the \"admin\" namespace in the \"room1\" room join the \"room2\" room\nio.of(\"/admin\").in(\"room1\").socketsJoin(\"room2\");\n```\n\n### `Emitter#socketsLeave(rooms:string|string[])`\n\nMakes the matching socket instances leave the specified rooms:\n\n```js\n// make all Socket instances leave the \"room1\" room\nio.socketsLeave(\"room1\");\n\n// make all Socket instances of the \"admin\" namespace in the \"room1\" room leave the \"room2\" room\nio.of(\"/admin\").in(\"room1\").socketsLeave(\"room2\");\n```\n\n### `Emitter#disconnectSockets(close:boolean)`\n\nMakes the matching socket instances disconnect:\n\n```js\n// make all Socket instances disconnect\nio.disconnectSockets();\n\n// make all Socket instances of the \"admin\" namespace in the \"room1\" room disconnect\nio.of(\"/admin\").in(\"room1\").disconnectSockets();\n\n// this also works with a single socket ID\nio.of(\"/admin\").in(theSocketId).disconnectSockets();\n```\n\n### `Emitter#serverSideEmit(ev:string[,...args:any[]])`\n\nEmits an event that will be received by each Socket.IO server of the cluster.\n\n```js\nio.serverSideEmit(\"ping\");\n```\n\n## License\n\n[MIT](./LICENSE)\n","readmeFilename":"README.md"}