0
我想要統計從手機連接到房間的用戶數量。但是,我不想統計連接到房間的所有用戶。計數用戶在手機上的房間
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