Is it possible to iterate over the connections and execute a block which would have access to the instance of MyHandler? (the server module)
On 12/29/06, Daniel Aquino <mr.danielaquino at gmail.com> wrote:> Is it possible to iterate over the connections and execute a block which > would have access to the instance of MyHandler? (the server module) > _______________________________________________ > Eventmachine-talk mailing list > Eventmachine-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/eventmachine-talk >No, there''s no built-in way to do that. Something like this might work, though: $ary = [] module YourMixin def post_init $ary << self end def unbind $ary.delete self end end
It seems to be working fine but there is one problem: When I iterate over $connections and send_data it appears to close each connection after sending the data! $connections.each do |connection| connection.send_data "Test" end Any idea why ? Francis Cianfrocca wrote:> On 12/29/06, Daniel Aquino <mr.danielaquino at gmail.com> wrote: >> Is it possible to iterate over the connections and execute a block which >> would have access to the instance of MyHandler? (the server module) >> _______________________________________________ >> Eventmachine-talk mailing list >> Eventmachine-talk at rubyforge.org >> http://rubyforge.org/mailman/listinfo/eventmachine-talk >> > > > No, there''s no built-in way to do that. Something like this might work, though: > > $ary = [] > > module YourMixin > def post_init > $ary << self > end > > def unbind > $ary.delete self > end > end > _______________________________________________ > Eventmachine-talk mailing list > Eventmachine-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/eventmachine-talk >
On 12/29/06, Daniel Aquino <mr.danielaquino at gmail.com> wrote:> It seems to be working fine but there is one problem: > > When I iterate over $connections and send_data it appears to close each > connection after sending the data! > > $connections.each do |connection| > connection.send_data "Test" > end > > Any idea why ? >That shouldn''t be happening. Are you sure the connections are actually still open when you call send_data on them? Without seeing the actual application run it''s hard to tell what''s happening.
Sorry it was an error in my client... Francis Cianfrocca wrote:> On 12/29/06, Daniel Aquino <mr.danielaquino at gmail.com> wrote: >> It seems to be working fine but there is one problem: >> >> When I iterate over $connections and send_data it appears to close each >> connection after sending the data! >> >> $connections.each do |connection| >> connection.send_data "Test" >> end >> >> Any idea why ? >> > > That shouldn''t be happening. Are you sure the connections are actually > still open when you call send_data on them? Without seeing the actual > application run it''s hard to tell what''s happening. > _______________________________________________ > Eventmachine-talk mailing list > Eventmachine-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/eventmachine-talk >