Enable communication between applications using web sockets
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 ...
RegisterDisconnect |
Call the callback function upon web socket disconnect |
sendMessage |
Send message to the web socket |
closeConnection |
Close web socket connection |
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")});
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);
Close the web socket connection
Example:
import { WebSocketService } from "@devopsstraxcorp/web-socket-service";
WebSocketService.closeConnection();