Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bugszhou/mini-websocket

小程序websocket
https://github.com/bugszhou/mini-websocket

Last synced: 1 day ago
JSON representation

小程序websocket

Awesome Lists containing this project

README

        

# mini-websocket
小程序websocket

### Usage

```
const socket = new MiniSocket('ws://localhost:7070/yt22u');
socket
.on('message', (err, msg) => {
console.log(msg);
})
.on('close', (err, { type }) => {
if (type === 'SERVER_CLOSE') {
console.log(''服务器已关闭'');
}
console.log('close ===> ', type);
})
.on('notopen', (err, data) => {
socket.reConnect({ data });
})
.on('reconnect', (err, { data }) => {
this.send(data);
console.log('reconnect ====> ', data);
})
.on('retryTimeout', () => {
console.log('retryTimeout');
})
.on('catch', () => {
console.log('catch');
});
```