1
나는 이것에 약간의 문제가있다. socket.io (works)를 다른 서버에 연결하고 있는데, WS에서 클라이언트 (처리)로 보내고 싶습니다. 주된 문제는 단지 한 번 보내는 것입니다. socket.io가 입력을받는 모든 시간을 보내고 싶습니다.WS websocket send() 함수로
실제 코드 :
socket.on('udp message', function(msg) {
temp = msg/100;
console.log(temp) ;
ws.send(temp.toString());
});
wss.on('connection', function(ws) {
console.log("Connected to client")
});
이런 식으로 내 WS 클라이언트에서 실시간 데이터를 가질 수있다 : 내가 원하는 무엇
var io = require("socket.io-client");
var socket = io.connect('http://socket.io.server:8000');
var WebSocketServer = require('ws').Server
, wss = new WebSocketServer({port: 8080});
var temp = 0;
socket.on('connect', function() {
console.log("socket connected") ;
});
socket.on('udp message', function(msg) {
temp = msg/100;
console.log(temp) ;
wss.on('connection', function(ws) {
ws.send(temp.toString());
});
});
. 당신은 하나의 웹 소켓 클라이언트를 처리해야하는 경우
예상대로 정상적으로 작동합니다. 감사!!! – user1343998