RingBase/broker — pull request #4 by andrewberls (2014-05-19 23:44:09+00:00)
Title: Overhaul Broker subscriber tracking

TLDR: we were using EventMachine channels incorrectly which is
responsible for all the weird broadcast bugs (ex: notes) we've been
seeing.

According to the docs [0], which are terrible, a Channel is a way to
push items to a number of subscribers. If you re-read that carefully,
you'll notice we were creating a new Channel for each subscriber, which
was effectively blowing out the others.

I implemented a solution that used a single channel and subscribed
agents to it, and then realized we didn't need it at all just using
built-in Goliath utilities.

We now keep a mapping of agent_id -> env, where env is the Rack
environment object given to us by Goliath. We can use the stream_send
method on any env to send a websocket message to that client, so now we
just do that.

This also adds the beginning of support for the event visualizer - the
node_event event (poorly named) will be sent from the Broker to the
EventCtrl in angular, which will handle updating the animation to
activate the appropriate node and show messages flowing through the
system.