JSON for WebSockets
As WebSockets gets closer to a final draft, the real question becomes: how should applications use it? While JSON is an obvious payload format, sending plain JSON payloads just doesn’t have enough structure for any non-demo application. I’m putting together a JSMP (JSON Message Protocol) rough draft, as a suggested JSON pattern for WebSockets.
JMTP is based on our experience with clustering in Resin for the last two years. While we use Hessian instead of JSON for the payload, the architecture and issues are the same.
- typed messages: basically object-oriented messages. Any significant application will have several message types, and using an object-oriented
type is a clean way to dispatch. - unidirectional messages and rpc queries: both styles are needed, and queries require a bit of protocol effort and definition to get right.
- addressing: larger applications should be decomposed into smaller services. With addressing, that architecture is trivial.
