【文件属性】:
文件名称:pubsub:创建自己的PubSub客户端和服务器Websocket
文件大小:21KB
文件格式:ZIP
更新时间:2021-05-13 02:58:17
JavaScript
pubsub
创建自己的PubSub客户端和服务器Websocket
客户
const pubSub = new PubSubClient ( 'ws://localhost:3001' , {
connect : true ,
reconnect : true ,
} )
const topicName = 'abc'
pubSub . subscribe ( topicName , ( message ) => {
console . log ( `Got message from topic ${ topicName } ` , message )
} )
//publish a message to topic
pubSub . publish ( topicName ,
{
【文件预览】:
pubsub-master
----.DS_Store(6KB)
----client()
--------webpack.config.js(409B)
--------src()
--------.babelrc(24B)
--------dist()
--------package.json(541B)
----.idea()
--------misc.xml(279B)
--------workspace.xml(18KB)
--------pubsub.iml(458B)
--------watcherTasks.xml(139B)
--------modules.xml(264B)
--------vcs.xml(180B)
----README.md(1KB)
----.gitignore(89B)
----server()
--------src()
--------package.json(972B)