Code-Sharp / WampSharp

A C# implementation of WAMP (The Web Application Messaging Protocol)
http://wampsharp.net
Other
385 stars 83 forks source link

Alternative transport support #103

Open BrannonKing opened 8 years ago

BrannonKing commented 8 years ago

I was considering writing a NetMQ (ZeroMQ) transport for WampSharp. However, in looking at the existing transports, it was not obvious how this could be accomplished. I figured I would just need to override a certain interface, but it looks like I need to inherit TextBinaryTransport<>, and I have no idea what is supposed to go in that generic parameter (or why its name is an oxymoron). Do we have any documentation on how to accomplish this?

darkl commented 8 years ago

We don't really have documentation about this. Do you plan to support multiple serialization types? WebSocket and RawSocket transports support both binary and text serialization based on handshake negotiation.

BrannonKing commented 8 years ago

I suppose I should support both binary and text. The NetMQ message get/put support both.

darkl commented 8 years ago

So the way to go is to inherit TextBinaryTransport. The generic parameter is the underlying real connection (i.e. the session object that NetMQ provides you). It is there so you get it in all relevant methods (the method that determines what subprotocol you are using, and the methods that create the text/binary WAMP connections). For implementing the IWampConnection interface, the base AsyncWampConnection class is provided. In this class the TMessage should remain a generic parameter which will be determined by the given user WampBinding.