java - Asynchronous websocket mechanism which pretend to be synchronous -
i not looking specific answer, idea or tip. have following problem:
android application client web service. has thread, sends events (xml form request id) through http protocol , every request server sends confirmation, understand message right granted event id - server synchronizer few clients. want use websocket protocol send events through websocket little bit tricky - instead of http, don't expect response every request. moreover, incoming websocket messages parsed in other thread. primary mechanism it's little bit overgrown , don't want write scratch.
i want make asynchronous websocket mechanism pretend synchronous. there idea - after send event through websocket wait no more e.g 5 seconds response processed in other thread (it's came xml) , regarding request id notify proper paused thread. worry condition.await() , condition.signal isn't best idea, think?
according problem, i've realized have problems project kind of mechanism. have idea, can find information pattern , tips avoid bad approach? in advance!
the difference between websocket , http requests lack of http headers when message comes in. in websocket, have heartbeat keeps connection alive , allows full duplex communication, , have pure payloads. it's job find message headers use route requests in server/client.
so, doesn't stop communicating in request/response manner writing output stream right after receiving. suggest take @ rfc
https://tools.ietf.org/html/rfc6455
if you're little more visual, slideshow can help:
http://www.slideshare.net/sergialmar/websockets-with-spring-4
or if want more serious implementations example, take @ spring's docs:
http://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html
Comments
Post a Comment