Skip to content

dartondox/dox-web-socket-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dox Websocket client

Installation

Via cdn
https://cdn.jsdelivr.net/npm/@dartondox/websocket/dist/index.js
Via npm or yarn
$ npm install @dartondox/websocket

OR

$ yarn add @dartondox/websocket

Usage

import DoxWebsocket from '@dartondox/websocket';

const socket = DoxWebsocket('ws://127.0.0.1:3001/ws', {
  maxRetries: 18, retryAfter: 2000 
})

socket.onConnected(() => {
  console.log(socket.id)
})

socket.onError(() => {
  console.log('socket error')
})

socket.on('intro', (msg) => {
  console.log(msg)
})

socket.onClose(() => {
  console.log('socket closed')
})

function send() {
  socket.emit('intro', { data: message.value })
}

About

Websocket client with retry function

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published