Skip to content

moeenn/durable-sockets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

durable-sockets

Native Javascript web sockets are not very nice. Mainly they have the following problems:

  • Any data to be sent or received over the websocket connection has to be manually encoded / decoded (generally in JSON).
  • If the server closes the connection, the client must manually detect this and attempt to reconnect the socket.
  • If the client attempts to send a message over a socket which if closed (or in process of closing) the message will be lost.

This package attempts to solve these issues.

Usage

/* configuring the websocket */
const socket = new DurableSocket(url, payload => {
  console.log("[message]", payload)
})

/* connecting a websocket */
socket.connect()

/* sending a message over the websocket */
socket.sendMessage({ message: "Hello world"})

About

Improvements over native JavaScript Web sockets

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published