我正在尝试计算通过电话连接到房间的用户数量。但是,我不想计算连接到房间的所有用户。
手机加载的Javascript:
socket.emit('mobilePlayer', {});
服务器
io.sockets.on('connection', function(socket){
socket.on('mobilePlayer', function(data){
socket.set('mobileClient', function(){
console.log('mobile client connected and set');
})
});
socket.on('join', function (data, ball) {
RoomModel.findById(data.room, 'title', function(err, room){
socket.get('mobilePlayer', function (err) {
MobilePlayerCount = io.sockets.clients('mobileClient').length; // Count mobile users
console.log(MobilePlayerCount);
});
}); // End RoomModel
}); // End Join
}); // End connection