@devopsstraxcorp/web-socket-service
v1.0.6
Published
Enable communication between applications using web sockets
Downloads
29
Readme
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();