Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bugszhou/mini-websocket
小程序websocket
https://github.com/bugszhou/mini-websocket
Last synced: 1 day ago
JSON representation
小程序websocket
- Host: GitHub
- URL: https://github.com/bugszhou/mini-websocket
- Owner: bugszhou
- Created: 2019-04-10T10:09:18.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-08T14:10:51.000Z (over 3 years ago)
- Last Synced: 2025-01-01T15:19:06.563Z (25 days ago)
- Language: JavaScript
- Size: 485 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
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');
});
```