FayeSwift icon indicating copy to clipboard operation
FayeSwift copied to clipboard

Single server messages should be serialized as JSON arrays

Open vrutberg opened this issue 8 years ago • 2 comments

Currently, FayeSwift serializes a single JSON message sent to the server as a JSON object. As stated in the Bayeux protocol specification, clients should send even single server messages as an array of messages, but server implementations are only required to accept an array of messages. Therefore, sending single messages as arrays practically guarantees compatibility with any server implementation.

All Bayeux messages SHOULD be encapsulated in a JSON encoded array so that multiple messages may be transported together. A Bayeux client or server MUST accept either array of messages and MAY accept a single message.

https://docs.cometd.org/current/reference/#_messages

I encountered this while trying to implement FayeSwift in an app that communicates with a Java CometD server, which only accepts arrays of messages.

vrutberg avatar Feb 02 '17 10:02 vrutberg

@vrutberg just say this... thanks for bringing this up. Are you able to submit a PR?

hamin avatar Feb 06 '17 23:02 hamin

yes, I'll give it a shot!

vrutberg avatar Feb 13 '17 12:02 vrutberg