Your First Union Application
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 the Room class
import net.user1.reactor.Room;
import net.user1.reactor.Reactor;
import net.user1.reactor.ReactorEvent;
public class UnionChat {
protected var reactor:Reactor;
// Define a variable to reference the chat's Room object
protected var chatRoom:Room;
public function UnionChat () {
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();
}
}
}