Skip to content
This repository has been archived by the owner on May 22, 2019. It is now read-only.

jawampa on jetty? #76

Open
zhuker opened this issue Dec 3, 2015 · 3 comments
Open

jawampa on jetty? #76

zhuker opened this issue Dec 3, 2015 · 3 comments

Comments

@zhuker
Copy link

zhuker commented Dec 3, 2015

where do i start if i wanted to run jawampa on jetty-websocket?

@Matthias247
Copy link
Owner

You need to implement a connection provider (similar to the netty connection provider which is contained in the jawampa-netty directory). This connection provider needs to implement the interfaces in the ws.wamp.jawampa.connection in order to push messages towards jawampa-core. The most important thing is IWampConnection, which you need to map to a Jetty websocket connection. If you only need the server side you don't need to implement the client-side interfaces and it should not be too much work.

@zhuker
Copy link
Author

zhuker commented Dec 3, 2015

yeah, i need server side only
i am very new to jawampa codebase so i cant tell right off the bat which interfaces are server-side
do you have a list i would need to implement?

@Matthias247
Copy link
Owner

I'm a little bit out of this project since I'm not actively working on it and have last touched it many month ago. But as far as I see it's only the IWampConnection one. Your jetty adapter has to accept websocket connections, needs to wrap them in IWampConnection interfaces and register them at the router. See here https://github.com/Matthias247/jawampa/blob/master/jawampa-netty/src/main/java/ws/wamp/jawampa/transport/netty/WampServerWebsocketHandler.java#L134-L187 for the wrapped class and later on https://github.com/Matthias247/jawampa/blob/master/jawampa-netty/src/main/java/ws/wamp/jawampa/transport/netty/WampServerWebsocketHandler.java#L243-L247 for registering at the router.

  • Important things as far as I can remember: The router and your websocket handler live in different threads. Therefore the calls between them must be threadsafe. The jawampa core interfaces IWampConnectionAcceptor and IWampConnectionListener are thread safe (if you call them the messages are put into a queue in the Routers thread) - be sure your IWampConnection methods are too.
  • Send and close methods are async. Be sure to fulfill the promises when you have finished the operation (and only then). Only after you have sent one message jawampa will give you the next.
  • jawampa will always call close() on the connection. Even after you have signaled a close to it.
  • Don't do weird things like calling messageReceived after transportClosed.
  • You need to do serialization and deserialization in your adapter. It isn't efficient to do it in jawampa core because we would then need to copy the Byte Buffers (whose datatype is networking library specific) into some general format. See WampSerializationHandler and WampDeserializationHandler for how it works. As all the heavy lifting is done by jackson anyway it's also not that complicated.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants