Reactor Chat Tutorial, Part 1

Creating and Joining the Chat Room

Within the application's readyListener(), we'll create the chat room and join it. Rooms are represented by instances of the Room class.

package {
  import flash.display.Sprite;

  import net.user1.reactor.Reactor;
  import net.user1.reactor.ReactorEvent;
  // Import the Room class
  import net.user1.reactor.Room;

  public class UnionChatPart1 {
    protected var reactor:Reactor;
    // Define a variable to reference the chat's Room object
    protected var chatRoom:Room;

    public function UnionChatPart1 () {
      reactor = new Reactor();
      reactor.addEventListener(ReactorEvent.READY, readyListener);
      reactor.connect("tryunion.com", 80);
    }

    protected function readyListener (e:ReactorEvent):void {
      // Ask the RoomManager to create the room on the server
      chatRoom = reactor.getRoomManager().createRoom("chatRoom");
      // Join the room
      chatRoom.join();
    }
  }
}

Pages: 1 2 3 4 5 6 7