EM.connect post_init question

31 views
Skip to first unread message

GregD

unread,
Apr 26, 2012, 3:55:31 PM4/26/12
to eventm...@googlegroups.com
All,

I have tried EM in the past. Trying it again, but lost on something so simple....

I have a module with this

def post_init
  puts "Established connection to server"
end

when I

EM.run {
  EM.connect <server-ip>, <server-port>, Module
}

The post_init is run even when a connection is not established.  Also, if I supply a block it is run.  It as if my client as made a connection when I know it has not.  What is wrong here? I'm using jruby and the java version of this, so maybe I need to ask the author of that.  But, I just wanted to clarify that this is not the correct behavior, right?

Using the Java version and JRuby to right a hardware simulator that is a client using Monkeybars and EM and StateMachine.  Any thoughts, if this is doable or suggestions?

Thanks,

GregD



 

Iñaki Baz Castillo

unread,
Apr 26, 2012, 6:44:21 PM4/26/12
to eventm...@googlegroups.com
2012/4/26 GregD <gdit...@fuse.net>:
> The post_init is run even when a connection is not established.  Also, if I
> supply a block it is run.

It's the correct behavior. Check:

https://github.com/eventmachine/eventmachine/wiki/FAQ

--
Iñaki Baz Castillo
<i...@aliax.net>

GregD

unread,
Apr 27, 2012, 8:56:27 AM4/27/12
to eventm...@googlegroups.com
Thanks.  I was mislead by this in the post_int description....

click to toggle source

EventMachine::Connection#post_init is called by the event loop immediately after the network connection has been established, 



On Thursday, April 26, 2012 6:44:21 PM UTC-4, Iñaki Baz Castillo wrote:
2012/4/26 GregD <>:
Reply all
Reply to author
Forward
0 new messages