Skip to content

Releases: github/stable-socket

v1.1.1

14 Oct 18:50
37641a2
Compare
Choose a tag to compare

What's Changed

  • Updated dependencies
  • Publish with provenance by @dgreif in #36

Full Changelog: v1.1.0...v1.1.1

v1.1.0

22 Oct 16:55
b345902
Compare
Choose a tag to compare

What's Changed

  • feat: add a new configurable reconnectWindow by @keithamus in #3

Full Changelog: v1.0.0...v1.1.0

1.0.0

14 Oct 16:48
v1.0.0
Compare
Choose a tag to compare

A stable release with no changes since 0.1.2.

0.1.1

13 Jul 18:16
v0.1.1
Compare
Choose a tag to compare

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()