@vasudhab/test-web-socket-service
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Web Socket Service

Enable communication between applications using web sockets

Quickstart

Connect to the web socket

1. Install

npm install @devopsstraxcorp/web-socket-service

2. Connect to Web socket

import { WebSocketService } from "@devopsstraxcorp/web-socket-service";
WebSocketService.connect(websocketURL, sessionId, clientId, tokenValidationEndpoint);

For sending messages and other options read on ...

Methods Summary

RegisterDisconnect Call the callback function upon web socket disconnect
sendMessage Send message to the web socket
closeConnection Close web socket connection

Methods

RegisterDisconnect

The callback to be called when the web socket has successfully disconnected.

Example:

import { WebSocketService } from "@devopsstraxcorp/web-socket-service";
 WebSocketService.RegisterDisconnect(()=> { console.log("web socket disconnected")});

sendMessage

Send message on web socket for all the connected applications

Example:

import { WebSocketService } from "@devopsstraxcorp/web-socket-service";

// create request object
    var dataObject = new WebSocketDataObject("Message to Send", sessionId);
    var message = new WebSocketRequestObject("onMessage", dataObject);

closeConnection

Close the web socket connection

Example:

import { WebSocketService } from "@devopsstraxcorp/web-socket-service";
WebSocketService.closeConnection();

Readme

Keywords

none

Package Sidebar

Install

npm i @vasudhab/test-web-socket-service

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

114 kB

Total Files

12

Last publish

Collaborators

  • vasudhab