# nodeJsChat **Repository Path**: Canton-Jack/nodeJsChat ## Basic Information - **Project Name**: nodeJsChat - **Description**: 使用nodejs+zookeeper 实现分布式聊天系统 - **Primary Language**: NodeJS - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2020-06-23 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README **分布式聊天工具设计** ### client --websocket-- server --websocket--client 其中 server有一个或多个,为了保证 client 把消息发送给任意一个server的client, 并且根据特定的人或人群指定发送 ### 实际架构如下 client - - - -server- - client client - --ws---server- --ws--- client client - - - -sevver- - client ### 流程 1.client 选择channel 2.client发送msg至server 3.server将消息写入对应channel (消息过大时考虑写入全局缓存(redis,或mongodb) 4.其他server监听到相应channel,读取消息,发送至对应client ### channel 模型结构 path1/path2/path3 利用zookeeper实现 世界--- |-path0 |-path1 -- |-path01 |-path1 -- |-path02 -- |-path2 ### client 操作指南 - ls [../channel] --列举当前消息渠道_ - add [../channel] --加入某个channel 可接受该渠道消息 - quit [../channel] --退出某个channel 取消接受该渠道消息 - send msg --发送消息 (只能发送到当前所拥有的channel)