Flooding Socket.IO节点服务器

时间:2015-06-23 07:12:10

标签: node.js sockets socket.io raspberry-pi

我正在使用Raspberry Pi和套接字进行交互式游戏,我从RPI向笔记本电脑上的服务器发送高速率(每个侦听器每秒1-20)。 在某些时候一切都很好,但有时候它会变得非常错误(需要几毫秒来显示变化)。

有没有办法优化与Socket.IO的通信,还是有其他方法可以做到这一点?

P.S。我正在做简单的发布,没有数据更轻。 编辑:

服务器:

socket.on('player1', function(){
    //doing calculations
});
socket.on('player2', function(){
    //doing calculations
});
socket.on('player3', function(){
    //doing calculations
});

客户端:

socket.emit('player1');
socket.emit('player2');
socket.emit('player3');

编辑2 这些是我从Pi接收发射时所做的“计算”,它是一些非常基本的RaphaelJS对象动画。

var pos = this.objects[index].getPointAtLength(this.counter[index]);
this.e[index].attr({
    x: pos.x, 
    y: pos.y
});
this.counter[index]++;

0 个答案:

没有答案