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.
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 aneventSetup
function that's just a long list ofsocket.on(...)
calls.