brybam
brybam

Reputation: 5019

onPeerConnect not working properly with adobe cirrus

Anyone familiar with using Cirrus? (http://labs.adobe.com/technologies/cirrus/) I'm having the hardest time getting the onPeerConnect object to work the way it should. I just need to be able to just take 1 sides nearID and give it to the other. and then when the near tries to connect to the far, the far should return true and allow connection, then at the same time grab the connecting farID on its own with farID = subscriber.farID; (which works, i confirmed it's getting the farID) but when i try this code it just see it getting spammed with....

TRUE
NetStream.Play.Start
NetStream.Play.Start
NetStream.Connect.Success
NetStream.Connect.Closed
TRUE
TRUE
NetStream.Play.Start
TRUE
NetStream.Play.Start
NetStream.Play.Start
NetStream.Connect.Closed
NetStream.Connect.Success
NetStream.Connect.Closed
TRUE
TRUE
TRUE
NetStream.Play.Start
NetStream.Connect.Closed
TRUE
NetStream.Play.Start
NetStream.Connect.Closed
TRUE
NetStream.Play.Start
TRUE
NetStream.Play.Start
NetStream.Play.Start
NetStream.Connect.Closed
NetStream.Connect.Success

over and over and over and over

So how can i get this work so, like i said only 1 side needs to be supplied with others farID and they can then pass audio and video to each other?

I've been rearranging the code for hours and playing with the location of the client = code among other things, but still no luck. can anyone share any insight on the topic?

//SETUP STREAM FUNCTION
                    public function setupStream():void
                    {


                        //send stream with audio and video;
                        sendStream = new NetStream(netConnection,NetStream.DIRECT_CONNECTIONS);

                        sendStream.attachAudio(live_mic);
                        sendStream.attachCamera(nearCam);
                        sendStream.addEventListener(NetStatusEvent.NET_STATUS, cirrusStatusHandler);



                        var c:Object = new Object;
                        c.onPeerConnect = function(subscriber:NetStream):Boolean {

                                farID = subscriber.farID;
                                trace("TRUE");
                                setupReceiveStream();
                                return true;


                        }
                        sendStream.client = c;
                        sendStream.publish("media");

                    }




    //receive stream function
                public function setupReceiveStream():void
                {
                    receiveStream = new NetStream(netConnection, farID);

                    //receive stream with audio and video;
                    receiveStream.client = this;
                    receiveStream.play("media");
                    far_video.mx_internal::videoPlayer.attachNetStream(receiveStream);
                    receiveStream.addEventListener(NetStatusEvent.NET_STATUS, cirrusStatusHandler);

                }

Upvotes: 0

Views: 1192

Answers (2)

Gábor DANI
Gábor DANI

Reputation: 2135

You dont check if the new incoming stream you set up in onPeerconnect extist. You should only initiate the new incoming stream, when that does not exist. This is why it is repeating itself.

Upvotes: 0

Related Questions