Title: quote
great to hear, this is the code i was talking about, it still needs alot of work since i added the fallback stuff in (yes flash player is suppose to but doesnt ;)), notice connect method and the switching of the rest argument, its impossible to overload that method and pass it properly !

    public class Connect extends NetConnection
    {
        private var code:String;
        private var _autoBandwidthDetection:Boolean = false;
        private var _fallBackServer:String;
        private var params:*;
        private var connectRetry:int = 0;
        public var ncInt:Array = new Array();
       
        public function Connect(encodeAMF0:Boolean = true)
        {
            setDefaultEncoding(encodeAMF0);
            super();
   
            this.addEventListener(NetStatusEvent.NET_STATUS, onStatus);
        }
       
        public function set fallBackServer(server:String):void
        {
            _fallBackServer = server;   
        }
       
        public function set autoBandWidthDetection(detect:Boolean):void
        {
            _autoBandwidthDetection = detect;
        }
   
        override public function connect(command:String, ... rest):void
        {
            this.params = rest;
   
            switch (rest.length)
            {
                case 0:
                    super.connect(command);
                    break;
                case 1:
                    super.connect(command, rest[0]);
                    break;
                case 2:
                    super.connect(command, rest[0], rest[1]);
                    break;
                case 3:
                    super.connect(command, rest[0], rest[1], rest[2]);
                    break;
            }
        }
       
        private function parseURL(url:String):Array
        {
            return url.split("://")
        }
       
        private function getURL(url:String):String
        {
            return parseURL(url)[1];
        }
       
        private function getProtocol(url:String):String
        {
            return parseURL(url)[0];
        }
       
        private function setDefaultEncoding(encodeAMF0:Boolean = true):void
        {
            if (encodeAMF0)
            {
           
                this.objectEncoding = flash.net.ObjectEncoding.AMF0;
            } else {
                this.objectEncoding = flash.net.ObjectEncoding.DEFAULT;
            }
        }
   
       
        public function onStatus(event:NetStatusEvent):void
        {
            switch (event.info.code)
            {
                case "NetConnection.Connect.Success":
                    this.dispatchEvent(new ConnectEvent(ConnectEvent.CONNECTED,false,false,ConnectEvent.CONNECTED_MSG));
                    stopReconnect();
                break;
                case "NetConnection.Connect.Failed":
                    nextConnect();
                break;
                case "NetConnection.Connect.Closed":
                    this.dispatchEvent(new ConnectEvent(ConnectEvent.DISCONNECTED,false,false,ConnectEvent.DISCONNECTED_MSG));
                break;
            }
           
        }
       
        private function stopReconnect():void
        {
            clearTimeout(this.ncInt[0]);   
        }
       
        private function nextConnect():void
        {
            trace("Couldnt connect to " + this.uri);
            this.ncInt[0] = setTimeout(tryFallBack, 1500);
        }
       
        private function tryFallBack():void
        {
            if (connectRetry > 1)
            {   
                stopReconnect();
                this.dispatchEvent(new ConnectEvent(ConnectEvent.FAILED,false,false,ConnectEvent.FAILED_MSG));
            } else {
                this.dispatchEvent(new ConnectEvent(ConnectEvent.RECONNECTED,false,false,ConnectEvent.RECONNECTED_MSG));
               
                var url:String = getURL(this.uri);
                this.close();
                this.connect("rtmpt://" + url);
                connectRetry++;
            }
        }
       
    }
}


John Kirby wrote:
Whooo Hooo!  Thijs  ... I owe you beer man!  Thanks

Thijs Triemstra said the following:
This should work..

private function setupStreaming():void
{
// ....
nc.client = this;
nc.connect("rtmp://localhost/oflaDemo");
}

public function catchVideos():void
{
// call server-side method
var nc_responder:Responder = new Responder(getMediaList, null);
nc.call("demoService.getListOfAvailableFLVs", nc_responder);
}

public function getMediaList (list:Object):void 
{
//
for(var items:String in list) {
if (typeof(list[items]) == "object") {
mediaList.push(list[items]);
for (var d:String in list[items]) {
trace(d + " - " + list[items][d]);
}
}
}
}

public function onBWDone():void 
{
}

Thijs

Op 9-nov-2006, om 1:52 heeft John Kirby het volgende geschreven:

Yes...

Here is what I get for the connection:

Not sure what the async error is about?

about to connect to: rtmp://infinitymedialabs.com:873/oflaDemo
asyncErrorHandler:code: ReferenceError: Error #1069: Property onBWDone not found on flash.net.NetConnection and there is no default value.
Connection:netStatusHandler:Success: connected:

Here's my connection logic.

public  function connectVideoSession():void{
                NetConnection.defaultObjectEncoding = ObjectEncoding.AMF0;
                SharedObject.defaultObjectEncoding  =  ObjectEncoding.AMF0;               
               
                nc = new NetConnection();
               
                nc.addEventListener( "success", connectionSuccessHandler );
                nc.addEventListener( AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler );
                nc .addEventListener( IOErrorEvent.IO_ERROR, ioErrorHandler );
                nc.addEventListener(NetStatusEvent.NET_STATUS, connectionStatusHandler);
                trace("about to connect to: " + connectionUrl);
                nc.connect( connectionUrl);
               
 }

In the connectionStatusHandler() I call  fetchVideos() (below) but don't get anything back?

Dan Rossi said the following:
Interesting, thats awesome.

im assuming you did this for the netconnect aswell ?

SharedObject.defaultObjectEncoding  =  ObjectEncoding.AMF0;   

I posted ages ago a helper class for netconnect which may be helpful dont know.

John Kirby wrote:
I am almost done with a Flex 2 version of oflademo.  I looked at the flash version (AS2) and I'm stuck on how to invoke the demoService getListOfAvailableFLVs to return the array?

This is what I'm trying with not result?


private function fetchVideos():void{
             //res = new Responder(listResponder);
             aResult = new Array();
             trace("Making call");
             SharedObject.defaultObjectEncoding  =  ObjectEncoding.AMF0;   
             /*
             trace ("URI: " + nc.uri);
             soVideoList = SharedObject.getRemote( "demoService.getListOfAvailableFLVs", nc.uri);
             soVideoList.addEventListener( NetStatusEvent.NET_STATUS, netStatusHandler );
             soVideoList.addEventListener( AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler );
             soVideoList.addEventListener( SyncEvent.SYNC, sharedObjectSyncHandler );
             soVideoList.client = this;
             soVideoList.connect( nc );
             soVideoList.send(aResult);
             */
             nc.call("demoService.getListOfAvailableFLVs", null, aResult);   
            trace ("RESPONSE2: " + aResult.length);
         
        }

As soon as this works I'll post.  I 'm adding a proxy server configuration as well as a "auto sizing" video display to show wide HD format (does it automatically).

Thanks.

.j


--
Whether you think that you can, or that you can't, you are usually right.
 - Henry Ford

_______________________________________________ Red5 mailing list [email protected] http://osflash.org/mailman/listinfo/red5_osflash.org


_______________________________________________ Red5 mailing list [email protected] http://osflash.org/mailman/listinfo/red5_osflash.org

--
Whether you think that you can, or that you can't, you are usually right.
 - Henry Ford
_______________________________________________
Red5 mailing list


_______________________________________________ Red5 mailing list [email protected] http://osflash.org/mailman/listinfo/red5_osflash.org

--
Whether you think that you can, or that you can't, you are usually right.
 - Henry Ford

_______________________________________________ Red5 mailing list [email protected] http://osflash.org/mailman/listinfo/red5_osflash.org



_______________________________________________
Red5 mailing list
[email protected]
http://osflash.org/mailman/listinfo/red5_osflash.org

Reply via email to