summaryrefslogtreecommitdiffstats
path: root/archives/extend/2013-August/000226.html
blob: 4fcc162069ea9ef9266de9be521304c735dc565d (plain) (blame)
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
 <HEAD>
   <TITLE> [99s-extend] [erlang-questions]  How to broadcaset with ranch?
   </TITLE>
   <LINK REL="Index" HREF="index.html" >
   <LINK REL="made" HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20%5Berlang-questions%5D%20%20How%20to%20broadcaset%20with%20ranch%3F&In-Reply-To=%3CCAPGJuCaYJnOn-Hq_GgQZV2pxmaUwCxbS372dapbnQiOZ8vWC%3Dw%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="000225.html">
   
 </HEAD>
 <BODY BGCOLOR="#ffffff">
   <H1>[99s-extend] [erlang-questions]  How to broadcaset with ranch?</H1>
    <B>Sean Cribbs</B> 
    <A HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20%5Berlang-questions%5D%20%20How%20to%20broadcaset%20with%20ranch%3F&In-Reply-To=%3CCAPGJuCaYJnOn-Hq_GgQZV2pxmaUwCxbS372dapbnQiOZ8vWC%3Dw%40mail.gmail.com%3E"
       TITLE="[99s-extend] [erlang-questions]  How to broadcaset with ranch?">seancribbs at gmail.com
       </A><BR>
    <I>Wed Aug 21 05:18:19 CEST 2013</I>
    <P><UL>
        <LI>Previous message: <A HREF="000225.html">[99s-extend] How to broadcaset with ranch?
</A></li>
        
         <LI> <B>Messages sorted by:</B> 
              <a href="date.html#226">[ date ]</a>
              <a href="thread.html#226">[ thread ]</a>
              <a href="subject.html#226">[ subject ]</a>
              <a href="author.html#226">[ author ]</a>
         </LI>
       </UL>
    <HR>  
<!--beginarticle-->
<PRE>This is exactly the sort of thing gen_event is for. I would make each
server process register a handler at startup using
gen_event:add_sup_handler() and then have the handle_event callback simply
relay the event to the server processes. Yes, gproc can do this, but why
incur its extra features and overhead?


On Sat, Aug 17, 2013 at 3:10 AM, Lo&#239;c Hoguin &lt;<A HREF="https://lists.ninenines.eu/listinfo/extend">essen at ninenines.eu</A>&gt; wrote:

&gt;<i> On 08/17/2013 10:00 AM, Bin Wang wrote:
</I>&gt;<i>
</I>&gt;&gt;<i> Hi,
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> I'm new to ranch. In my application, I need to send some message to
</I>&gt;&gt;<i> all connections. So I'd like to know can I get all connections from
</I>&gt;&gt;<i> ranch, so I could use Transport:send to send them, or I must manage
</I>&gt;&gt;<i> all the created connections by myself? Or is there any other better
</I>&gt;&gt;<i> way?
</I>&gt;&gt;<i>
</I>&gt;<i>
</I>&gt;<i> The best way to do that is on your end, using gproc properties. When the
</I>&gt;<i> connection is accepted, register the process with the property and use the
</I>&gt;<i> property to send messages to all processes. You don't need to unregister
</I>&gt;<i> when the connection ends, gproc does that automatically.
</I>&gt;<i>
</I>&gt;<i> The hackish way to do that would be to call supervisor:which_children on
</I>&gt;<i> the ranch_conns_sup supervisor of your listener, but that will slow down
</I>&gt;<i> the accepting of new connections, so don't do this if you need high accept
</I>&gt;<i> rates.
</I>&gt;<i>
</I>&gt;<i> --
</I>&gt;<i> Lo&#239;c Hoguin
</I>&gt;<i> Erlang Cowboy
</I>&gt;<i> Nine Nines
</I>&gt;<i> <A HREF="http://ninenines.eu">http://ninenines.eu</A>
</I>&gt;<i>
</I>&gt;<i> ______________________________**_________________
</I>&gt;<i> erlang-questions mailing list
</I>&gt;<i> <A HREF="https://lists.ninenines.eu/listinfo/extend">erlang-questions at erlang.org</A>
</I>&gt;<i> <A HREF="http://erlang.org/mailman/**listinfo/erlang-questions&lt;http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/**listinfo/erlang-questions&lt;http://erlang.org/mailman/listinfo/erlang-questions</A>&gt;
</I>&gt;<i>
</I>-------------- next part --------------
An HTML attachment was scrubbed...
URL: &lt;<A HREF="http://lists.ninenines.eu/archives/extend/attachments/20130820/b203ebe2/attachment.html">http://lists.ninenines.eu/archives/extend/attachments/20130820/b203ebe2/attachment.html</A>&gt;
</PRE>

<!--endarticle-->
    <HR>
    <P><UL>
        <!--threads-->
	<LI>Previous message: <A HREF="000225.html">[99s-extend] How to broadcaset with ranch?
</A></li>
	
         <LI> <B>Messages sorted by:</B> 
              <a href="date.html#226">[ date ]</a>
              <a href="thread.html#226">[ thread ]</a>
              <a href="subject.html#226">[ subject ]</a>
              <a href="author.html#226">[ author ]</a>
         </LI>
       </UL>

<hr>
<a href="https://lists.ninenines.eu/listinfo/extend">More information about the Extend
mailing list</a><br>
</body></html>