Releases: github/stable-socket
Releases · github/stable-socket
v1.1.1
v1.1.0
What's Changed
- feat: add a new configurable reconnectWindow by @keithamus in #3
Full Changelog: v1.0.0...v1.1.0
1.0.0
0.1.1
StableSocket
A web socket that reconnects.
Installation
$ npm install @github/stable-socket
Usage
import {StableSocket} from '@github/stable-socket'
const delegate = {
socketDidOpen(socket: Socket) {
// Socket is ready to write.
socket.send('Hello')
},
socketDidClose(socket: Socket, code?: number, reason?: string) {
// Socket closed and will retry the connection.
},
socketDidFinish(socket: Socket) {
// Socket closed for good and will not retry.
},
socketDidReceiveMessage(socket: Socket, message: string) {
// Socket read data from the connection.
}
}
const policy = {
timeout: 4000,
attempts: Infinity,
maxDelay: 60000
}
const socket = new StableSocket('wss://live.example.com', delegate, policy)
socket.open()