Your First Union Application

Waiting for the Connection to be Ready

When the connection is established and ready for use, Reactor dispatches a ReactorEvent.READY event. Applications must wait for that event before starting, like this:

package {
  import flash.display.Sprite;
  import net.user1.reactor.Reactor;
  // Import the ReactorEvent class
  import net.user1.reactor.ReactorEvent;

  public class UnionChat {
    protected var reactor:Reactor;

    public function UnionChat () {
      reactor = new Reactor();
      // Triggers readyListener() when the connection is ready
      reactor.addEventListener(ReactorEvent.READY,
                                  readyListener);
      reactor.connect("tryunion.com", 80);
    }

    // Method invoked when the connection is ready
    protected function readyListener (e:ReactorEvent):void {
    }
  }
}

Pages: 1 2 3 4 5 6 7