News for hackers. Stuff that matters.
Re:Show HN: 3D multiplayer space shooter made with Three.js by rezoner on Wednesday June 05, 2019 @08:16AM (#20103586)
If you don't have better ideas for improving your packet size at least push your JSON through msgpack. Using strings as keys (properties) is ultra bad for your bandwidth too. In general JSON is only suitable for turn based games.
Re:Show HN: 3D multiplayer space shooter made with Three.js by redka on Wednesday June 05, 2019 @11:54AM (#20105675)
For my games[1] I use a custom binary protocol which is not that difficult to pull off. Actually building a buffer with JavaScript's DataView[2] and ArrayBuffers produces very compact results since you're free to optimize the packets for each specific game - for example a single uInt8 can store 8 different flags for a game character - things like dead/alive, up/down, right/left, walking/running, etc.

[1] https://redka.games [2] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Re:Show HN: 3D multiplayer space shooter made with Three.js by stcredzero on Wednesday June 05, 2019 @02:48PM (#20107865)
If you don't have better ideas for improving your packet size at least push your JSON through msgpack.

I'm about to change over to msgpack for my own multiplayer real time browser game. I'd use protobuf, but the extra code generation step would get in the way of my plans to turn my MMO into an MMO-game-as-lambdas PaaS project.

Right now, I'm using my own protocol which uses something somewhat like base-85 for encoding, except it's base-92. It's a binary packing format, but packs directly into base-92 encoding. This packed base-92 is encapsulated into JSON, which minimizes the use of keys. This might all sound horrible, but I'm able to achieve what Flatpack achieves: no copies are needed to extract the data. That, and the remaining slight JSON overhead makes it easier to debug network traffic.

Re:Show HN: 3D multiplayer space shooter made with Three.js by nickyvanurk on Wednesday June 05, 2019 @08:27AM (#20103668)
Thanks for pointing this out. This will be my next improvement.
Re:Show HN: 3D multiplayer space shooter made with Three.js by rezoner on Wednesday June 05, 2019 @08:46AM (#20103792)
ps: Don't use the official implementation - it is slow. Go with one of the lite projects like that one https://github.com/kawanet/msgpack-lite
Re:Show HN: 3D multiplayer space shooter made with Three.js by nickyvanurk on Wednesday June 05, 2019 @08:49AM (#20103807)
Much appreciated!
Re:Show HN: 3D multiplayer space shooter made with Three.js by echelon on Wednesday June 05, 2019 @09:40AM (#20104198)
Protobuf would be an excellent serialization. It's compact, binary, and efficient. There's a ton of library support in nearly every language imaginable.
Re:Show HN: 3D multiplayer space shooter made with Three.js by arendtio on Saturday June 08, 2019 @04:17AM (#20131271)
I am not 100% sure, but I think I read somewhere (at least 2 years ago), that browsers are actually faster using JSON than Protobuf (a bit counter-intuitive).

Nevertheless, bandwidth-wise it could make sense anyway, but I think it makes sense to consult some benchmarks in this case.