mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 09:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,101 @@
|
||||
package org.osmf.utils
|
||||
{
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.net.NetConnection;
|
||||
import flash.utils.Timer;
|
||||
|
||||
public class FCSubscribeHandler
|
||||
{
|
||||
|
||||
private var maxRetry:Number = 5;
|
||||
|
||||
private var currentTry:Number = 0;
|
||||
|
||||
private var retryTimer:Timer;
|
||||
|
||||
private var nc:NetConnection;
|
||||
|
||||
private var owner:Object;
|
||||
|
||||
public var nsName:String;
|
||||
|
||||
public function FCSubscribeHandler()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function run(param1:String, param2:String, param3:Object) : void
|
||||
{
|
||||
this.nsName = param1;
|
||||
this.owner = param3;
|
||||
nc = new NetConnection();
|
||||
nc.addEventListener("netStatus",netConnectHandler);
|
||||
nc.client = this;
|
||||
nc.connect(param2);
|
||||
}
|
||||
|
||||
protected function netConnectHandler(param1:NetStatusEvent) : void
|
||||
{
|
||||
trace("NC: " + param1.info.code);
|
||||
if(param1.info.code == "NetConnection.Connect.Success")
|
||||
{
|
||||
fcSubscribeRetry();
|
||||
}
|
||||
else if(param1.info.code == "NetStream.Play.UnpublishNotify")
|
||||
{
|
||||
trace("publish");
|
||||
}
|
||||
else if(param1.info.code == "NetStream.Unpublish.Success")
|
||||
{
|
||||
trace("unpublish");
|
||||
}
|
||||
}
|
||||
|
||||
private function fcSubscribeRetry() : void
|
||||
{
|
||||
retryTimer = new Timer(1000,3);
|
||||
retryTimer.addEventListener("timerComplete",retryFCSubscribe);
|
||||
retryTimer.start();
|
||||
}
|
||||
|
||||
private function retryFCSubscribe(param1:TimerEvent) : void
|
||||
{
|
||||
if(currentTry != maxRetry)
|
||||
{
|
||||
nc.call("FCSubscribe",null,nsName);
|
||||
currentTry = currentTry + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
cleanupTimer();
|
||||
}
|
||||
}
|
||||
|
||||
public function onFCSubscribe(param1:Object) : void
|
||||
{
|
||||
trace(param1.code);
|
||||
if(param1.code != "NetStream.Play.StreamNotFound")
|
||||
{
|
||||
if(param1.code == "NetStream.Play.Start")
|
||||
{
|
||||
cleanupTimer();
|
||||
trace("ready to play");
|
||||
owner.fcSubscribeDone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onFCUnpublish(param1:Object) : void
|
||||
{
|
||||
trace("hi");
|
||||
}
|
||||
|
||||
private function cleanupTimer() : void
|
||||
{
|
||||
retryTimer.stop();
|
||||
retryTimer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user