You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I tried to implement setInterval in the block ws.onmessage with the following code:
ws.on('message', function incoming(message) {
console.log('received: %s', message);
setInterval(function(){
ws.send('message from server at: ' + new Date());
},10*1000);
connectedUsers.push(message);
});
And this was triggered by the client's code:
function socket_data () {
wsocket = new WebSocket('ws://localhost:3000/socketdata');
wsocket.onopen = function () {
console.log('client is trying to open websocket for realtime data...');
wsocket.send('request_data');
}
wsocket.onmessage = function (evt) {
console.log(evt.data);
}
}
Now, how to implement close/terminate the socket connection?
The text was updated successfully, but these errors were encountered:
Hello, I tried to implement setInterval in the block ws.onmessage with the following code:
And this was triggered by the client's code:
Now, how to implement close/terminate the socket connection?
The text was updated successfully, but these errors were encountered: