3 Replies Latest reply on Nov 14, 2013 5:08 PM by Michael Thornburgh

    startTransmit / stopTransmit reference error on NetStream when connecting to device

    tigui.plante Level 1

       

      Hi all,

      I'm trying to create a P2P connection between a mobile device (Android) and a PC using the NetStream class.

      When the connection is established, the Flash Player Instance on the PC is crashing with a reference error:
      “Property startTransmit not found on flash.net.NetStream”

       

      I have seen the thread located located here: http://stackoverflow.com/questions/9676496/adobe-cirrus-error-on-direct-connectproperty-st arttransmit-not-found-on-flash-n
      but was not successfull in making it work with my code.

       

      I have tried extending the NetStream class like so:

      import com.frimastudio.cosy.util.NetConsole;
      import flash.net.NetConnection;
      import flash.net.NetStream;

      public class NetStreamProvider extends NetStream
      {
        public function NetStreamProvider (connection:NetConnection, peerID:String)
        {
         super(connection, peerID);
        }
       
        // For AIR Android projects: when the device is put to sleep for a moment, this function will be
        // called so we need to implement it to prevent flash from crashing.
        public function startTransmit($p1:*, $p2:*):void
        {
         COSY::console { NetConsole.WarningInternal("NetInterfaceSlot", "startTransmit", "startTransmit called"); }
        }

        public function stopTransmit():void
        {
         COSY::console { NetConsole.WarningInternal("NetInterfaceSlot", "stopTransmit", "stopTransmit called"); }
        } 
       
      }

       

      and using the NetStreamProvider instead. Without success.

      Any help would be greatly appreciated.

      Thanks.

      --
      Guillaume

        • 1. Re: startTransmit / stopTransmit reference error on NetStream when connecting to device
          Michael Thornburgh Adobe Employee

          i have seen this before but never run into it myself. i suspect this is AIR-specific (probably if AIR is the sender) -- in my experience it doesn't happen with plain Flash Player.

           

          it looks like you're trying to add startTransmit() and endTransmit() methods directly to a NetStream subclass.  the example solution you posted from stackoverflow shows adding those methods as properties to a client object.  i have found that often NetStream "event" methods MUST be methods (and sometimes property functions) of a client object, not methods of a NetStream subclass.

           

          try making an object with those method names and assign it to netStream.client.  you might need to make them be property functions instead of proper methods.  gross i know.

          • 2. Re: startTransmit / stopTransmit reference error on NetStream when connecting to device
            tigui.plante Level 1

            >> i suspect this is AIR-specific (probably if AIR is the sender) -- in my experience it doesn't happen with plain Flash Player.

             

            [Guillaume] -> Right, it does not happen on NetStreams between 2 Flash Players and 2 AIR app. Only between AIR-FlashPlayer NetStreams. Basically, after a stream is opened between AIR and Flash Player, the AIR is calling "starTransmit" on the FlashPlayer NetStream, wich is not implemented.

             

            >> try making an object with those method names and assign it to netStream.client

             

            [Guillaume] -> I tried the following:

            • Implement starTransmit/stopTransmit functions in the NetStream.client object
            • Implement startTransmit/stopTransmit functions in the NetStream instance (subclassed)

             

            Without success. Basically, it works fine if I just create a "dummy" client object for the NetStream that has those 2 functions. But If I want to use my own client it was still crashing.

             

            I found a work around for my problem.

             

            My NetStream object is sub classed as such:

             

            ----------------------------------

            public class NetStreamProvider extends NetStream

            {

              public var customClient:Object;

             

              public function NetStreamProvider (connection:NetConnection, peerID:String)

              {

               super(connection, peerID);

              

               customClient = new Object();

               this.client = customClient;

              

               // Implement startTransmit and stopTransmit here for dummy client

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

                var subClient:Object=new Object();

                subClient.stopTransmit=function($p1:*,$p2:*):void{

                 trace("Cosy: stopTransmit called",$p1,$p2);

                }

                subClient.startTransmit=function():void{

                 trace("Cosy: startTransmit called");

                }

                subscriber.client = subClient;

               

                return true;

               }

              }

             

              public function SetClient(c:Object):void

              {

               this.client = c;

              }

             

              public function OnNetStreamAsyncError(event:AsyncErrorEvent):void

              {

                ...

              }

            }

            ----------------------------------

             

            And in the stream status event handler, when the stream is ready (events "NetStream.Play.PublishNotify" and "NetStream.Play.Start") I set the correct client, which has the receive handler. At that point startTransmit was already called:

             

            And in the stream status event handler, when the stream is ready (events "NetStream.Play.PublishNotify" and "NetStream.Play.Start") I set the correct client, which has the receive handler. At that point startTransmit was already called:

             

            ----------------------------------

            private function OnNetStreamStatus(e:NetStatusEvent)

            {

            switch(e.info.code)

            {

              case "NetStream.Play.PublishNotify":

              {       

                       stream = e.target as NetStreamProvider;

                       stream.SetupClient(client);

              }

              break;

              case "NetStream.Play.Start":

              {                        

                       stream = e.target as NetStreamProvider;

                       stream.SetupClient(client);

              }

              break;

            }…

            }

            ----------------------------------

             

             

            At this point, i'm not blocked anymore. However, it would be good to know why, when and who are calling those functions to understand the issue. this is not documented anywhere, and might be an issue to a lot of people now that we are starting to see more and more cross-platform connectivity.

             

            Cheers.

             

            --

            Guillaume

            • 3. Re: startTransmit / stopTransmit reference error on NetStream when connecting to device
              Michael Thornburgh Adobe Employee

              Guillaume: thanks for drilling down on this. i will try to look into it and see what's causing this. i agree it's not good that 1) this happens at all and 2) that it's not documented.