Socket.IO

client.on not getting data on single connect

回眸只為那壹抹淺笑 提交于 2020-12-11 12:16:03
问题 I am using net module to connect client with my server. And here is my code. const Net = require('net'); client = Net.connect(parseInt(port), host, function() { console.log('server connected') }) console.log("ooooooooooooooooooooooooooooo") client.on('data', function(chunk) { let data = chunk.toString() console.log(data) }); client.on('error', function(error) { console.error('error', error); }); The issue is when I connect it with single client it doesn't give me data inside client.on('data'

client.on not getting data on single connect

♀尐吖头ヾ 提交于 2020-12-11 12:15:02
问题 I am using net module to connect client with my server. And here is my code. const Net = require('net'); client = Net.connect(parseInt(port), host, function() { console.log('server connected') }) console.log("ooooooooooooooooooooooooooooo") client.on('data', function(chunk) { let data = chunk.toString() console.log(data) }); client.on('error', function(error) { console.error('error', error); }); The issue is when I connect it with single client it doesn't give me data inside client.on('data'

how to get socket.io number of clients in room?

北城以北 提交于 2020-12-11 04:38:40
问题 my socket.io version 1.3.5 I want to get number of clients in particular room. This is my code. socket.on('create or join', function (numClients, room) { socket.join(room); }); I use this code for get clients in room : console.log('Number of clients',io.sockets.clients(room)); 回答1: To get the number of clients in a room you can do the following: function NumClientsInRoom(namespace, room) { var clients = io.nsps[namespace].adapter.rooms[room]; return Object.keys(clients).length; } This

how to get socket.io number of clients in room?

為{幸葍}努か 提交于 2020-12-11 04:35:47
问题 my socket.io version 1.3.5 I want to get number of clients in particular room. This is my code. socket.on('create or join', function (numClients, room) { socket.join(room); }); I use this code for get clients in room : console.log('Number of clients',io.sockets.clients(room)); 回答1: To get the number of clients in a room you can do the following: function NumClientsInRoom(namespace, room) { var clients = io.nsps[namespace].adapter.rooms[room]; return Object.keys(clients).length; } This

how to get socket.io number of clients in room?

狂风中的少年 提交于 2020-12-11 04:34:39
问题 my socket.io version 1.3.5 I want to get number of clients in particular room. This is my code. socket.on('create or join', function (numClients, room) { socket.join(room); }); I use this code for get clients in room : console.log('Number of clients',io.sockets.clients(room)); 回答1: To get the number of clients in a room you can do the following: function NumClientsInRoom(namespace, room) { var clients = io.nsps[namespace].adapter.rooms[room]; return Object.keys(clients).length; } This

Chrome Extension Socket io node js

两盒软妹~` 提交于 2020-11-30 06:13:45
问题 I need to create a chrome extension which shows a notification when we get a message from socket io node js server. How to include socket io in chrome extension? I am not able to get this to working. Content.js:- Uncaught ReferenceError: io is not defined var socket = io.connect('http://localhost:1337'); socket.on("hello",function(data){ console.log(data.text); chrome.runtime.sendMessage({msg:"socket",text:data.text},function(response){}); }); Manifest:- This is not importing socket io Failed

Chrome Extension Socket io node js

不想你离开。 提交于 2020-11-30 06:08:01
问题 I need to create a chrome extension which shows a notification when we get a message from socket io node js server. How to include socket io in chrome extension? I am not able to get this to working. Content.js:- Uncaught ReferenceError: io is not defined var socket = io.connect('http://localhost:1337'); socket.on("hello",function(data){ console.log(data.text); chrome.runtime.sendMessage({msg:"socket",text:data.text},function(response){}); }); Manifest:- This is not importing socket io Failed