🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

broadcastnodejs

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broadcastnodejs

server端主动发送广播给客户端

latest
npmnpm
Version
0.0.9
Version published
Weekly downloads
1
-96.43%
Maintainers
1
Weekly downloads
 
Created
Source

广播

server端主动发送广播给客户端

client

client分为:user和group两种。

user是指一个user在只允许一个链接注册(一个链接对应js意味着一个io.connection)。

group是指一个group可以允许多个链接注册。

调用register事件进行注册,

注册完成之后,假如有第三方或者服务内部需要发送给你信息,那么会根据你注册的user和group进行数据发送,你们之间只需约定好事件名称即可。

假如需要注销,不再收到消息,则可以调用unRegister事件进行注销。

broadcastInfo用于第三方发送给对应user或者group数据,相应事件eventName和内容text(内容可以是文本或者json)。

注:假如发送目标group包含发送人自己,发送人是不会收到消息的。

client javascript

请求目录下有对应JS包,目前采用socket.io 2.1.0

  • 代码例子

    
      
      
    

客户端可以发送三个公共事件:register,unRegister,broadcastInfo。

register

  • 用户名,重复注册,会自动注销之前注册的用户

例子:{"user": "6A2C1FBC70FE38EEE050007F010061E5"}

  • 群组,允许重复注册

例子:{"group": "vvv"}

unRegister

  • 注销用户名

例子:{"user": "6A2C1FBC70FE38EEE050007F010061E5"}

  • 注销群组

例子:{"group": "vvv"}

broadcastInfo

  • roomName 发送房间名

  • eventName 发送事件名称

  • text 发送内容

例子:{"roomName":"xxx","eventName":"countMsg","text":"99"} {"roomName":"xxx","eventName":"countMsg","text":{"data","sdfdsf"}}

client java

之后补充!!!!

npm:This link

docket:This linke

FAQs

Package last updated on 31 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts