1.0.1 • Published 12 months ago

shuai-websocket-js v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
12 months ago

使用手册

引用

import WebSocket from 'shuai-websocket-js';

创建链接

    WebSocket.createSocket('ws://121.40.165.18:8800');

发送消息

    WebSocket.sendWSPush({ name: 'hello' });

接收消息

	```
const getsocketData = (e) => {
###  创建接收消息函数
  const data = e && e.detail.data;
  console.log(data);
};
	```

注册监听事件

	```
window.addEventListener('onmessageWS', getsocketData);
	```

在需要的时候卸载监听事件,比如离开页面

	```
// window.removeEventListener('onmessageWS', getsocketData)

	```
1.0.1

12 months ago

1.0.0

12 months ago