timely icon indicating copy to clipboard operation
timely copied to clipboard

Modify web socket response formats

Open klucar opened this issue 8 years ago • 3 comments

I found a good convention for JSON messages over web sockets, and suggest we switch to it. Basically we would always reply with a JSON array, the first element of the array is the operation and the second entry is the JSON data.

Current format:

{
  "operation" : "suggest",
  "sessionId" : "<value of TSESSIONID>",
  "type" : "metrics",
  "q" : "sys.cpu",
  "max" : 30
}

Suggested Format:

[  "suggest",
{
  "sessionId" : "<value of TSESSIONID>",
  "type" : "metrics",
  "q" : "sys.cpu",
  "max" : 30
}
]

Reference: https://www.new-bamboo.co.uk/blog/2010/02/10/json-event-based-convention-websockets/

An alternative to investigate is the WAMP setup: http://wamp-proto.org Which has a Java Jetty implementation at: http://www.connectanum.com/index.html

klucar avatar Aug 24 '16 14:08 klucar

Looks like connectanum is a pay service.

klucar avatar Aug 24 '16 14:08 klucar

Makes sense when we batch responses over the web socket. I don't think we are currently doing that.

dlmarion avatar Aug 24 '16 14:08 dlmarion

Web socket responses are batched in 0.0.4, but the format has not yet been changed to what was suggested.

dlmarion avatar Jan 23 '17 18:01 dlmarion