1.0.5 • Published 2 years ago

@mr-mahawar/lib-ws-web v1.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Web Socket Library for Web

Simple wrapper to maintain Web Socket connection made in TypeScript. In development ⚙️

Install

npm i @mr-mahawar/lib-ws-web

Usage

import  { createWebScoket }  from  '@mr-mahawar/lib-ws-web';

const  done  =  createWebScoket(
    WS_URL,
    {
	    onOpen: yourOnOpenListener,
	    onMessage: yourOnMessageListener,
	    onClose: yourOnCloseListener,
	    onError: yourOnErrorListener
    }
);

In your listeners you will receive the web-socket event directly. These are all optional.

For sending any message or closing the web-socket connection we have these functions that we can import: import { sendMessage, closeConnection } from '@mr-mahawar/lib-ws-web';

sendMessage('Your message!'); //Accepts string  |  ArrayBufferLike  |  Blob  |  ArrayBufferView 
closeConnection(); //This will close the connection

More features to come...

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago