union 接続テスト
/**
* Copyright keno42 ( http://wonderfl.net/user/keno42 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/fEad
*/
package {
import net.user1.reactor.*;
import flash.display.Sprite;
import flash.text.*;
public class FlashTest extends Sprite {
private var tf:TextField = new TextField();
private var server:String = "tryunion.com";
private var port:int = 9100;
private var reactor:Reactor = new Reactor();
public function FlashTest() {
// write as3 code here..
reactor.addEventListener(ReactorEvent.READY, onReady);
reactor.addEventListener(ReactorEvent.PROTOCOL_INCOMPATIBLE, onProtocolIncompatible);
reactor.addEventListener(ReactorEvent.CLOSE, onClose);
reactor.connect(server,port);
addChild(tf);
tf.autoSize = "left";
tf.appendText(server+":"+port+" に接続中です...\n");
}
private function onReady(e:ReactorEvent):void{
tf.appendText("接続完了しました\n");
}
private function onClose(e:ReactorEvent):void{
tf.appendText("切断されました\n");
}
private function onProtocolIncompatible(e:ReactorEvent):void{
tf.appendText("プロトコルが不適合です(サーバーUPCバージョン:"+e.getServerUPCVersion()+", クライアントUPCバージョン:"+reactor.getSystem().getUPCVersion()+")\n");
}
}
}