1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE> [99s-extend] Websocket vs. Request-Response msg pair
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20Websocket%20vs.%20Request-Response%20msg%20pair&In-Reply-To=%3CCAABECY1-3dxX337kaShnxa3EuH1OAUyKVgonLoM9qAOQN6DNvw%40mail.gmail.com%3E">
<META NAME="robots" CONTENT="index,nofollow">
<style type="text/css">
pre {
white-space: pre-wrap; /* css-2.1, curent FF, Opera, Safari */
}
</style>
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="000540.html">
<LINK REL="Next" HREF="000543.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[99s-extend] Websocket vs. Request-Response msg pair</H1>
<B>Graham Hay</B>
<A HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20Websocket%20vs.%20Request-Response%20msg%20pair&In-Reply-To=%3CCAABECY1-3dxX337kaShnxa3EuH1OAUyKVgonLoM9qAOQN6DNvw%40mail.gmail.com%3E"
TITLE="[99s-extend] Websocket vs. Request-Response msg pair">grahamrhay at gmail.com
</A><BR>
<I>Wed Jun 24 12:19:39 CEST 2015</I>
<P><UL>
<LI>Previous message: <A HREF="000540.html">[99s-extend] Websocket vs. Request-Response msg pair
</A></li>
<LI>Next message: <A HREF="000543.html">[99s-extend] Websocket vs. Request-Response msg pair
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#541">[ date ]</a>
<a href="thread.html#541">[ thread ]</a>
<a href="subject.html#541">[ subject ]</a>
<a href="author.html#541">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>I think you'd have to roll your own, you just need some way to correlate
<<A HREF="http://www.enterpriseintegrationpatterns.com/CorrelationIdentifier.html">http://www.enterpriseintegrationpatterns.com/CorrelationIdentifier.html</A>>
responses
with the originating request. OTP does something similar under the hood
with gen_server calls <<A HREF="http://www.erlang.org/doc/man/gen_server.html#call-2">http://www.erlang.org/doc/man/gen_server.html#call-2</A>>
.
It's also possible to treat the ws connection as a messaging channel, and
use something like selective consumer
<<A HREF="http://www.enterpriseintegrationpatterns.com/MessageSelector.html">http://www.enterpriseintegrationpatterns.com/MessageSelector.html</A>> to
de-multiplex the messages. e.g. you could add a type/channel field to each
message, and only subscribe to those messages.
Remember that once you move into an async world, there are no guarantees
that you will receive a response! So you need to start thinking about
timeouts etc.
On 24 June 2015 at 10:18, Robert Balogh <<A HREF="https://lists.ninenines.eu/listinfo/extend">ethrbh at gmail.com</A>> wrote:
><i> hello,
</I>><i>
</I>><i> According to you grate support I got from you at yesterday, I could
</I>><i> continue my project, where I use Cowboy webserver and using Websocket. Now
</I>><i> I made an own web page with basic features I need, so the server and client
</I>><i> can communicates to eachother. I like it.
</I>><i>
</I>><i> Now I would like to step forward, and I would like to implement a
</I>><i> Request-Response mechanism. I read few articles in to this topic, and all
</I>><i> of them has mentioned this "feature" is not part of the Websocket standard.
</I>><i> They were suggested to use some sub-protocols for this, but I did not see
</I>><i> any written in Erlang.
</I>><i>
</I>><i> So, I would like to ask you, do I understand right that Cowboy does not
</I>><i> have this feature too? If so, do you have some idea how can I implement a
</I>><i> basic request-response mechanism? Probably one of you guys in this forum
</I>><i> have some idea.
</I>><i>
</I>><i> Btw, the links I read about this topic:
</I>><i>
</I>><i> <A HREF="http://stackoverflow.com/questions/10882370/websocket-request-response-subprotocol">http://stackoverflow.com/questions/10882370/websocket-request-response-subprotocol</A>
</I>><i> <A HREF="http://alabor.me/articles/request-response-oriented-websockets/">http://alabor.me/articles/request-response-oriented-websockets/</A>
</I>><i> <A HREF="https://www.npmjs.com/package/primus-responder">https://www.npmjs.com/package/primus-responder</A>
</I>><i>
</I>><i> thanks for your help,
</I>><i> /Robi
</I>><i>
</I>><i> _______________________________________________
</I>><i> Extend mailing list
</I>><i> <A HREF="https://lists.ninenines.eu/listinfo/extend">Extend at lists.ninenines.eu</A>
</I>><i> <A HREF="https://lists.ninenines.eu/listinfo/extend">https://lists.ninenines.eu/listinfo/extend</A>
</I>><i>
</I>><i>
</I>-------------- next part --------------
An HTML attachment was scrubbed...
URL: <<A HREF="http://lists.ninenines.eu/archives/extend/attachments/20150624/6d15706e/attachment.html">http://lists.ninenines.eu/archives/extend/attachments/20150624/6d15706e/attachment.html</A>>
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="000540.html">[99s-extend] Websocket vs. Request-Response msg pair
</A></li>
<LI>Next message: <A HREF="000543.html">[99s-extend] Websocket vs. Request-Response msg pair
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#541">[ date ]</a>
<a href="thread.html#541">[ thread ]</a>
<a href="subject.html#541">[ subject ]</a>
<a href="author.html#541">[ author ]</a>
</LI>
</UL>
<hr>
<a href="https://lists.ninenines.eu/listinfo/extend">More information about the Extend
mailing list</a><br>
</body></html>
|