1 Reply Latest reply on Mar 15, 2011 2:03 AM by BryBam

    onPeerConnect triggering "failed" event rather than "rejected" event on a return false

    BryBam

      I was able to get onpeerconnect to return false if someone calls the receiver side (while the receiver side is already in a call with someone else), and it shows up as NetStream.Play.Failed (shouldnt it be rejected??) on the 3rd persons far side. This causes a problem when the 2 that are in a call stop, it all the sudden does a unpublish notify event, then my onpeerconnect returns true automatically and lets the 3rd person connect to the person they sent an invite to. How do I stop this behavior? How would i just make it return false, and i'd like to to just simply reject it(instead its giving the far side a "failed" event) and it would be ideal if it would just give up and NOT get notified when the stream is available?

       

      I'm currently using something like,

       

       

       

          var c:Object = new Object;

          c.onPeerConnect = function(subscriber:NetStream):Boolean {

          trace(userStatus+"== user status")

          if(userStatus == userStatusConnected)

          {

          trace("RETURNED TRUE");

          userStatus = userStatusInCall;

          return true;

          }

          else

          {

          trace("RETURNED FALSE");

          return false;

          }

          };

          sendStream.client = c;

          sendStream.publish("media");

       

       

       

       

       

      I dont really just dont understand why if it's returning false, why it still triggers a netstream.connect.success on the receiving side..which is weird. Why isn't it just not triggering any netstream on the receiving side. Then the far side should be seeing...NetStream.Connect.Rejected but instead it just gets a "failed" event. and it's getting notified when the far side stops?? this is probably happening because it's still connecting to the netstream even though i have confirmed its returning false...

       

       

       

       

       

       

        • 1. Re: onPeerConnect triggering "failed" event rather than "rejected" event on a return false
          BryBam Level 1

          It would be really helpful if someone could help explain onPeer Connect to me.


          i've been messing with it for days now and still have yet to get it to work how i'd like.


          the main issue i have is while using...

           

           

          var c:Object = new Object;

          c.onPeerConnect = function(subscriber:NetStream):Boolean {

          if(sendStream.peerStreams.length == 0)

          {

          trace("RETURNED TRUE");

          farID = subscriber.farID;

          return true;

           

          }

          else

          {

          trace("RETURNED FALSE");

          return false;

           

          }

          };

          sendStream.client = c;

          sendStream.publish("media");

           

           

           

           

          I just dont want another user to be able to connect if someone is in a call.


          What exactly is happening is...PERSON A calls PERSON B, person A gets the return TRUE from PERSON B.


          THEN, I HAVE PERSON C CALL PERSON B and i see the return FALSE trigger, and PERSON A and B stay in a call together. BUT, PERSON C can hear and see PERSON B.


          Some things I've noticed was, when PERSON C triggers the return FALSE on PERSON B they get a "NetSream.Play.Failed" event. and at the sametime it triggers a "NetStream.Connect.Success" Event on the PERSON B side. which doesn't make any sense to me because it returned false.


          I tried putting a receiveStream = null; in the "NetSream.Play.Failed" switch just to make sure, but every single time PERSON C can see and hear PSERSON B, even after PSERSON A and B disconnect from each other PERSON B is being watched and doesnt even know.



          So why is it triggering a connect on the side its return false on?


          and why is it even getting a failed result instead of a reject result?


          also, i dont see how its still getting content if i'm nulling out the receive stream?


          and whats even weirder is i put

           

          trace(sendStream.peerStreams.length + "## of SEND STREAM PEERS");

           

          trace(receiveStream.peerStreams.length + "## of RECEIVE STREAM PEERS");

           

          in the failed event listener without the null value and both streams are 0..


          I'm confused, and any insight on onpeerconnect would be so helpful