All of the EM code I''ve written is either servers or clients started
inside an EM.run{} block. However I recently ran into a situation
where I want access to the reactor outside of the block, and it
actually works (but not in jruby). For example:
thread = Thread.new { EventMachine.run { } }
... Make http client connection here using built in http client
protocol (code straight from the example)
thread.join
And it works... Which makes me wonder how does ruby code know of the
reactor is running?
In jruby though I get this...
/usr/local/jruby_trunk/lib/ruby/gems/1.8/gems/eventmachine-java-0.9.0/lib/jeventmachine.rb:78:in
`connect_server'': undefined method `connectTcpServer'' for
nil:NilClass
(NoMethodError)
from
/usr/local/jruby_trunk/lib/ruby/gems/1.8/gems/eventmachine-java-0.9.0/lib/eventmachine.rb:624:in
`connect''
from
/usr/local/jruby_trunk/lib/ruby/gems/1.8/gems/eventmachine-java-0.9.0/lib/protocols/httpclient.rb:70:in
`request''
from
/usr/local/jruby_trunk/lib/ruby/gems/1.8/gems/eventmachine-java-0.9.0/lib/protocols/httpclient.rb:70:in
`request''