I have an angular application needing to subscribe to a websocket for incoming data.
On the angular side, in a service I have ` setContextChannel(channel) { this.contextWS = new WebSocket(channel); that = this; this.contextWS.onmessage = function(event) { console.log('ws', event.data); that.patientID = event.data; };
this.contextWS.onerror = function(event) {
console.log('ws error', event);
}
}
and on the mock server side, I have a typescript node server that creates the socket as follows:
`import {Server} from "ws";
var wsServer: Server = new Server({port: 8085}); console.log('ws on 8085'); wsServer.on('connection',websocket => websocket.send('first pushed message'));
my question is how to use the wsServer to send messages?
via reza
No comments:
Post a Comment