mtm-ws-socket
v0.0.39
Published
Downloads
13
Readme
MtmWsSocket
MtmWsSocket is a wrapper for the different web socket clients available
For node.js, you can use this command to install:
npm install mtm-ws-socket
import the service:
import { MtmWsSocket } from "mtm-ws-socket";
USE assuming you have injected the service using the _mtmWsSock variable name:
var ssl = true;
var ip = "127.0.0.1";
var port = 6653;
var socket = this._mtmWsSock.getClients().getNative();
if (ssl === true) {
socket.setConnection("tls", ip, port);
socket.setSslConnection(true);
} else {
socket.setConnection("tcp", ip, port);
}
//specify the function that should handle ingress messages takes a single argument
socket.setIngressCb(this, "ingressHandler");
//send a message
socket.sendMessage("hello");