Closed om26er closed 7 years ago
Nearly;)
What we usually do in AB libraries for WebSocket:
So a WebSocket client announces a list of WebSocket subprotocols to use: wamp.2.cbor, wamp.2.json
and the server (Crossbar.io) will chose the first one it is willing/able to speak.
RawSocket is simpler: http://wamp-proto.org/static/rfc/draft-oberstet-hybi-crossbar-wamp.html#handshake
There is no negotiation during the opening handshake.
So for (Netty based) WebSocket in ABJ, I see these options:
a)
As Jackson has CBOR, JSON and MessagePack support built in anyway by default (is this true?), let the NettyTransport
just announce all 3 (list of WebSocket subprotocols), with order cbor>msgpack>json, and then actually use the serializer chosen by the router.
No API change at all. But no client (user) influence also.
b)
public NettyTransport(String uri, List<ISerializer> serializers, ExecutorService executor)
Same as above, but only announce exactly the serializers that the user wants.
With both, the WebSocket client class in ABJ then really needs to pay attention to the actual WebSocket subprotocol chosen by the router, as that will determine which serializer to use.
So what about the max WebSocket frame size parameter ? also what should be the default value of that (currently 655360),
Shall we add more serializers(json, msgpack) today or is that something for future ?
rgd websocket options, best would be to add https://github.com/crossbario/autobahn-java/blob/master/autobahn/src/main/java/io/crossbar/autobahn/websocket/WebSocketOptions.java#L20 as another parameter to (an overload of) the constructor of NettyTransport
.
rgd serializer support: for completeness we probably want to add it (json and msgpack, not ubjson, as the latter is not supported by Jackson?) now, as it is straight forward, not a lot work. this despite that a user may have little reasons to use anything else but CBOR.
rgd serializer support: for completeness we probably want to add it (json and msgpack, not ubjson, as the latter is not supported by Jackson?) now, as it is straight forward, not a lot work. this despite that a user may have little reasons to use anything else but CBOR.
One reason might be if someone is using a WAMP router that does not talk CBOR, but I am not sure how much we care about that.
@om26er yes, WAMP routers without CBOR support: of course Crossbar.io supports all serializers, but we want to play nice with other WAMP routers too. So yes.
This PR https://github.com/crossbario/autobahn-java/pull/246 adds MessagePack and JSONSerializers.
public NettyTransport(String uri, List
serializers, ExecutorService executor)
regarding this, the currently proposed implementation takes List of String instead of List of ISerializer so that we only construct a serializer when needed.
Merged the branch as that was blocking me. If we want to take a different approach for the above question, we can come back to it later.
We need to be able to define which wamp protocol to use (e.g. wamp.2.cbor or wamp.2.json etc). Right now its hardcoded. We also need to be able to define the max websocket framesize which is currently hard coded to 655360.
The relevant code is here