私は受信データ用にwebsocketを購読する必要のある角度のあるアプリケーションを持っています。typescript websocketでメッセージを送信する方法
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'));//////
私の質問:私は
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);
}
}
を持ち、モックサーバ側で、私は次のようにソケットを作成typescriptです・ノード・サーバーを持っているサービスに角度側では
、 wsServerを使ってメッセージを送信する方法は?
感謝はあなたのリンクに記載されています。 websocket.on( 'message'、私が探していたものです – reza
素晴らしいです。 –