hawkrobe / reference_games

Conventions in iterated reference games
8 stars 8 forks source link

Use json for all socket.io message-passing #24

Open hawkrobe opened 7 years ago

hawkrobe commented 7 years ago

A long time ago, I thought it would be simpler to route all socket messages through a single on_message function rather than making users set up separate callbacks.

This has a major drawback, though, which is that you're forced to use strings instead of richer data structures like json. When sending multiple pieces of data in the string, you need some separator that can be used to parse it (e.g. .) and this causes a bunch of bugs, where people try to send decimal values containing that special character. I think it's not that much more complicated for people to export an eventSetup function that's just a long list of socket.on(...) calls.