I found this example of using faye for a chatroom type app as I am
trying to get a feel for push servers:
I got some of that to work, although multiuser from the same browser
doesn't exactly make sense.
I then tried to look into a server side client. I am using a windows
laptop for everything.
I have the following code below which publishes a message to the
chatroom fine, but it never really exits.
The last statement "puts 'end'" is never reached. If I put EM.stop or
an exit statement inside the event machine block, then the messages
don't make it to the chat room.
The other thin I noticed is if I have a loop that puts say 5 messages
to the chat room, but sleeps for several seconds between each. They
don't show up until they have all been published. It's like it needs
to reach the bottom of the block, but once there it never exits the
block.
Your post has been very helpful, I tried something like what you
posted, but it didn't
quite make sense to me.
If you look at what I have currently below, I have to have this
sleep(30) at the bottom which is not optimal.
a join on the thread doesn't work.
I also tried run_block() instead of run() with no luck.
I guess if I do everything inside of a EM that doesn't take too long,
it wouldn't matter, but I am trying to get an idea of
how this sort of thing should work
Ok, Rails is a single threaded application, once you start event machine inside the application flow, control is lost until a event triggers a return somehow.