[99s-extend] Websocket vs. Request-Response msg pair

Loïc Hoguin essen at ninenines.eu
Wed Jun 24 12:28:21 CEST 2015


On 06/24/2015 11:18 AM, Robert Balogh wrote:
> Now I would like to step forward, and I would like to implement a
> Request-Response mechanism. I read few articles in to this topic, and
> all of them has mentioned this "feature" is not part of the Websocket
> standard. They were suggested to use some sub-protocols for this, but I
> did not see any written in Erlang.
>
> So, I would like to ask you, do I understand right that Cowboy does not
> have this feature too? If so, do you have some idea how can I implement
> a basic request-response mechanism? Probably one of you guys in this
> forum have some idea.

Cowboy only comes with the Websocket protocol itself, all sub protocols 
and mechanisms you want can then be implemented on top of it.

I strongly recommend not to do RPC. Just send events to the server and 
let the server send events to you. The difference is in the fact that 
RPC tracks what requests were sent to tie requests and responses 
together, while an event channel does not. You just send what the user 
is doing and the server sends you what it wants the client to update or 
do. Stay as stateless as possible.

If you need to manage state to update the interface (locking a form 
while waiting for the result, for example), do use timeouts to avoid 
locking endlessly.

Try and experiment, it's not very complicated. :-)

-- 
Loïc Hoguin
http://ninenines.eu
Author of The Erlanger Playbook,
A book about software development using Erlang


More information about the Extend mailing list