{"_id":"3h-room","_rev":"1-5d7dedb069b5b56c193c12e68755ae09","name":"3h-room","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"3h-room","version":"0.1.0","description":"A simple lib for SSE room management.","main":"dist/index.js","type":"commonjs","types":"dist/index.d.ts","scripts":{"prebuild":"node -e \"fs.existsSync('dist') && fs.rmSync('dist', { recursive: true })\"","build":"tsc","test":"node ./test/app.cjs","docs":"dts2md \"**/*.d.ts\" \"!index.d.ts\" -i ./dist -o ./docs -l -I Home.md"},"repository":{"type":"git","url":"git+https://github.com/huang2002/3h-room.git"},"keywords":["backend","room","management","member","sse","3h"],"author":{"name":"3h"},"license":"ISC","bugs":{"url":"https://github.com/huang2002/3h-room/issues"},"homepage":"https://github.com/huang2002/3h-room#readme","devDependencies":{"@types/express":"^4.17.21","@types/node":"^20.8.0","dts2md":"^0.4.4","express":"^4.18.2","typescript":"^5.2.2"},"dependencies":{"3h-sse":"^0.3.2"},"gitHead":"71f20b0df62a4ccfc83f11083753fe3548ae2a41","_id":"3h-room@0.1.0","_nodeVersion":"20.10.0","_npmVersion":"8.3.0","dist":{"integrity":"sha512-Og1BSsxHcetDdu2JjUA1aX05Ihn/2tAmO0HAZvxbic/s628590j69tZNhOPpwlSxnjeLDSSpnTMDXd8iVCm2dg==","shasum":"3bea3be97148c7ec3f58e820723b5c4642fcd9e2","tarball":"https://registry.npmjs.org/3h-room/-/3h-room-0.1.0.tgz","fileCount":38,"unpackedSize":57254,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCOig99o20RjNeLvLVLt6GFy1ey+BvQfX/JsWAREiXXVQIhAPK+HadYekSZV1++Xv2/H+MYB32VZfofmb3OcMaXCduV"}]},"_npmUser":{"name":"3h","email":"1340545944@qq.com"},"directories":{},"maintainers":[{"name":"3h","email":"1340545944@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/3h-room_0.1.0_1705882816854_0.24848633511233853"},"_hasShrinkwrap":false},"0.2.0":{"name":"3h-room","version":"0.2.0","description":"A simple lib for SSE room management.","main":"dist/index.js","type":"commonjs","types":"dist/index.d.ts","scripts":{"prebuild":"node -e \"fs.existsSync('dist') && fs.rmSync('dist', { recursive: true })\"","build":"tsc","test":"node ./test/app.cjs","docs":"dts2md \"**/*.d.ts\" \"!index.d.ts\" -i ./dist -o ./docs -l -I Home.md"},"repository":{"type":"git","url":"git+https://github.com/huang2002/3h-room.git"},"keywords":["backend","room","management","member","sse","3h"],"author":{"name":"3h"},"license":"ISC","bugs":{"url":"https://github.com/huang2002/3h-room/issues"},"homepage":"https://github.com/huang2002/3h-room#readme","devDependencies":{"@types/express":"^4.17.21","@types/node":"^20.8.0","dts2md":"^0.4.4","express":"^4.18.2","typescript":"^5.2.2"},"dependencies":{"3h-sse":"^0.3.2"},"gitHead":"829c637241628c5c1c8d26d7892a52b49c6b93cb","_id":"3h-room@0.2.0","_nodeVersion":"20.10.0","_npmVersion":"8.3.0","dist":{"integrity":"sha512-4ihgz88Z0zFkMwqAB8IFEUH7ezmfugJS3kn+iaK2LtEv9y/YxKUDrJEh+HD+V2Qrn6oJko5wYs8+RJ6zyH5OUg==","shasum":"98ea053532c4a9ec4d50c2898da8cc3791d59fe9","tarball":"https://registry.npmjs.org/3h-room/-/3h-room-0.2.0.tgz","fileCount":38,"unpackedSize":59303,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDZylSrFAWTwYJuVLSsCOmjZkeKEWgieMJIAQFhRBvWnAiAUYuTzj1/zskZSQyXOiqNSGPUpT2r0N8AIqwImLs4ZIg=="}]},"_npmUser":{"name":"3h","email":"1340545944@qq.com"},"directories":{},"maintainers":[{"name":"3h","email":"1340545944@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/3h-room_0.2.0_1705905997181_0.1744288431237606"},"_hasShrinkwrap":false}},"time":{"created":"2024-01-22T00:20:16.853Z","0.1.0":"2024-01-22T00:20:17.066Z","modified":"2024-01-22T06:46:37.562Z","0.2.0":"2024-01-22T06:46:37.366Z"},"maintainers":[{"name":"3h","email":"1340545944@qq.com"}],"description":"A simple lib for SSE room management.","homepage":"https://github.com/huang2002/3h-room#readme","keywords":["backend","room","management","member","sse","3h"],"repository":{"type":"git","url":"git+https://github.com/huang2002/3h-room.git"},"author":{"name":"3h"},"bugs":{"url":"https://github.com/huang2002/3h-room/issues"},"license":"ISC","readme":"# 3h-room\r\n\r\n> A simple lib for SSE room management.\r\n\r\n## Example\r\n\r\nHere's an example SSE room server based on express:\r\n\r\n```js\r\nconst express = require('express');\r\nconst SSE = require('3h-sse');\r\nconst HR = require('3h-room');\r\n\r\nconst app = express();\r\n\r\nconst createSSEController = () =>\r\n    new SSE.SSEController({\r\n        backend: new SSE.NodeJSBackend(),\r\n    })\r\n\r\nconst room = new HR.Room({\r\n    maxMemberCount: 2,\r\n    sseController: createSSEController(),\r\n});\r\n\r\nroom.on('enter', (member) => {\r\n    member.sendEvent('info', 'welcome');\r\n})\r\n\r\napp.get('/sub/:name', (req, res) => {\r\n\r\n    const member = new HR.Member({\r\n        identity: decodeURIComponent(req.params.name),\r\n        response: res,\r\n        sseController: createSSEController(),\r\n    });\r\n\r\n    member.on('enter', (_room) => {\r\n        _room.sendEvent('debug', 'member entered: ' + member.identity);\r\n    });\r\n    member.on('leave', (_room) => {\r\n        _room.sendEvent('debug', 'member left: ' + member.identity);\r\n    });\r\n\r\n    try {\r\n        room.addMember(member);\r\n    } catch (error) {\r\n        res.status(403);\r\n        res.end();\r\n        return;\r\n    }\r\n\r\n    res.once('close', () => {\r\n        room.removeMember(member);\r\n    });\r\n\r\n});\r\n\r\napp.listen(8080);\r\n```\r\n\r\n## Links\r\n\r\n- [API Reference](https://github.com/huang2002/3h-room/wiki)\r\n- [Changelog](./CHANGELOG.md)\r\n- [License (ISC)](./LICENSE)\r\n","readmeFilename":"README.md"}