iso-websocket
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

iso-websocket NPM Version License iso-websocket

iso-websocket implements the Websocket interface and is compatible with the browser, node.js and any other engine that implements basic Web APIs.

Features

  • Standard API and isomorphic
  • Reconnects automatically on close, connection timeout and connectivity events
  • Supports connection timeout
  • Extensible retry strategy with shouldRetry option and node-retry
  • Queue messages while offline, disconnected or reconnecting
  • Supports custom url callback to reconnect to a different url
  • Extensive tests
  • Typed events

Install

pnpm install iso-websocket

Usage

import { WS } from 'iso-websocket'

const ws = new WS('ws://localhost:8080')

ws.addEventListener('message', (e) => {
  console.log(e.data)
})

ws.send('hello')

ws.close()

Docs

Check https://hugomrdias.github.io/iso-repo/modules/iso_websocket.html

License

MIT © Hugo Dias

Package Sidebar

Install

npm i iso-websocket

Weekly Downloads

9

Version

0.2.0

License

MIT

Unpacked Size

29.6 kB

Total Files

11

Last publish

Collaborators

  • hugomrdias