D
D
Dmitry2015-09-11 07:00:35
JavaScript
Dmitry, 2015-09-11 07:00:35

How to optimize transmitted traffic through socket.io?

I am writing a Node.Js client-server game, during the game there is an exchange of a large amount of information about objects with their coordinates.
I wondered what would reduce traffic, please tell me which implementation will eat less traffic and how much less?

obj = {  
   x: 1472,
    y: 1963,
    radius: 10,
    border: 3,
    filled: 0,
    different: 4,
    mass: 1,
    hue: 192,
    sides: 6 
}	
    socket.emit(obj)

or
var obj = new Float32Array([1472,1963,10,3,0,4,1,192,6]).buffer;
  socket.emit(obj)

and is it possible to somehow measure transmitted packets via socket.io in order to know whether it is worth bothering with this at all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Yarosh, 2015-09-11
@voidnugget

If deflate is used, there is no point in pressing it.
You can play around with JSZip, but this will create additional overhead.
If you want to create an efficient protocol, it's better to use protobuf .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question