Embedding sessions into a router
Closed this issue · 3 comments
If you look at some example Autobahn code or most of the other implementations of WAMP in other languages, they allow you to optionally embed an ApplicationSession directly into a router (i.e. this autobahn example).What is the best way to reproduce this behavior with the turnpike API?
Currently the way to do something like that is to use a localPeer
. See, for example, how it's used in router_test.go.
It's not very easy to do that right now, so I would love to hear any proposals for a better mechanism. I suppose something like what Autobahn|Python has done could be implemented by embedding a Turnpike-supplied struct into an application-defined one.
You can now use Router.GetLocalPeer, but in practice you'd probably get this from WebsocketServer.GetLocalClient (falls back to creating a websocket connection if there's an error making the local client) since the Router isn't exported.
I think this has been answered well enough. Feel free to open another issue if this isn't sufficient.