WebSocket provides a bi-directional communication like a human being talks. The client can send data to the server and the server can send data to the client anytime. But wh
I would use JSON-RPC 2.0.
http://www.jsonrpc.org/specification
Each message would be a JSON object. The protocol states if it is a call that wants a response (coupling with id), or a notification.
A JSON-RPC aware application could easily check if the message object contains a method, signifying a call, or not, signifying a response.
I'm about to build a javascript lib to handle json rpc over websocket, with ajax as fallback…