LegionSB/isis — pull request #3 by jebler (2012-02-21 06:19:31+00:00)
Title: Chat History + Event Machine

I resolved the issue with Isis failing to stay connected to the engineering_room. When the server sent history, some of the history was malformed. This caused xml errors, regexp errores, and connection errors all after a random amount of time after connecting. I found some published code where they overode the join method and included a special history element with `maxstanzas="0"` this prevents history from being sent.

No more malformed history, no more waiting n seconds before responding to messages.

--

At first I thought that when I used `Thread.new { EM.run }` that two instances of event machine were colliding with each other. So, I wrapper the entire application in an EM.run block. (Causing subsequent event machines to use the parent reactor, instead of spawning a new thread). I also converted run to use a periodic timer instead of sleeping and counting. This did not help solve the issue, but now Isis can leverage evented network connections, timers, deferred processing, file monitors, and more. Plus, EventMachine is pretty cool to begin with, and this doesn't add any dependencies.