mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-21 01: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(nsName:String, url:String, owner:Object) : void
|
||||
{
|
||||
this.nsName = nsName;
|
||||
this.owner = owner;
|
||||
this.nc = new NetConnection();
|
||||
this.nc.addEventListener(NetStatusEvent.NET_STATUS,this.netConnectHandler);
|
||||
this.nc.client = this;
|
||||
this.nc.connect(url);
|
||||
}
|
||||
|
||||
protected function netConnectHandler(event:NetStatusEvent) : void
|
||||
{
|
||||
trace("NC: " + event.info.code);
|
||||
if(event.info.code == "NetConnection.Connect.Success")
|
||||
{
|
||||
this.fcSubscribeRetry();
|
||||
}
|
||||
else if(event.info.code == "NetStream.Play.UnpublishNotify")
|
||||
{
|
||||
trace("publish");
|
||||
}
|
||||
else if(event.info.code == "NetStream.Unpublish.Success")
|
||||
{
|
||||
trace("unpublish");
|
||||
}
|
||||
}
|
||||
|
||||
private function fcSubscribeRetry() : void
|
||||
{
|
||||
this.retryTimer = new Timer(1000,3);
|
||||
this.retryTimer.addEventListener(TimerEvent.TIMER_COMPLETE,this.retryFCSubscribe);
|
||||
this.retryTimer.start();
|
||||
}
|
||||
|
||||
private function retryFCSubscribe(event:TimerEvent) : void
|
||||
{
|
||||
if(this.currentTry != this.maxRetry)
|
||||
{
|
||||
this.nc.call("FCSubscribe",null,this.nsName);
|
||||
++this.currentTry;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.cleanupTimer();
|
||||
}
|
||||
}
|
||||
|
||||
public function onFCSubscribe(info:Object) : void
|
||||
{
|
||||
trace(info.code);
|
||||
if(info.code != "NetStream.Play.StreamNotFound")
|
||||
{
|
||||
if(info.code == "NetStream.Play.Start")
|
||||
{
|
||||
this.cleanupTimer();
|
||||
trace("ready to play");
|
||||
this.owner.fcSubscribeDone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onFCUnpublish(info:Object) : void
|
||||
{
|
||||
trace("hi");
|
||||
}
|
||||
|
||||
private function cleanupTimer() : void
|
||||
{
|
||||
this.retryTimer.stop();
|
||||
this.retryTimer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user