7 Replies Latest reply: Jun 27, 2012 11:59 AM by mmah-umd RSS

    TypeError: Stream.destroy is not a function

    Tomas_Mirezko Community Member

      Hello Adobe geeks!

       

      I am trying to destroy a NetStream published from client -- application.onUnpublish handler

       

      but I get this error: TypeError: Stream.destroy is not a function

       

      According to http://help.adobe.com/en_US/flashmediaserver/ssaslr/WS5b3ccc516d4fbf351e63e3d11a11afc95e-7 e42.html#WSdcb604046d78cda0-add5b6512f9ccc2d4e-8000

       

      Example

      The following example destroys a stream called streamA:

      // Get a stream. 
      streamA = Stream.get("clientStream1"); 
      // Destroy the stream. 
      Stream.destroy(streamA);

       

      Call Stream.destroy() to unlink and clean up a stream resource.

       

      application.onUnpublish = function (client /*Client*/, stream /*Stream*/) {
          trace("Application.onUnpublish > client " + client.userId + " stopped publishing " + stream.name);
      
          Stream.destroy();
      }
      

       

      How can I remove a stream created by user?

       

      Thanks!

       

      T.

        • 1. Re: TypeError: Stream.destroy is not a function
          Nikhil Pavan Kalyan Community Member

          Hi,

           

          Thanks for your interest.

           

          Stream.destroy() is a server side function that is available through scripting on the server. I guess you are trying to use it on the NetStream object on the client side which is not possible.

           

          You may need to make a server side stream object for your client's stream and as per the documentation resource you referred, you should be able to destoy the stream.

           

          Hope it helps. Thank you  !

          • 2. Re: TypeError: Stream.destroy is not a function
            Tomas_Mirezko Community Member

            Thank you for your reply.

             

            In fact I am using this particular SSAS:

             

            application.onUnpublish = function (client /*Client*/, stream /*Stream*/) {
                trace("Application.onUnpublish > client " + client.userId + " stopped publishing " + stream.name);
            
                Stream.destroy(stream);
            }

             

            this client side AS3:

             

            sendMulticast = new NetStream(serverConnection, NetStream.CONNECT_TO_FMS);
            sendMulticast.addEventListener(NetStatusEvent.NET_STATUS, _onSendMulticastNetStatus, false, 0, true);
            sendMulticast.publish("multicast_" + m_nearClientId);
            

             

            Thanks!

             

            T.

             

            Message was edited by: Tomas_Mirezko, added client side code

            • 3. Re: TypeError: Stream.destroy is not a function
              Nikhil Pavan Kalyan Community Member

              Thanks for the code snippet. Even though you are using the Stream.destroy on the server side, you are still trying to destroy a client side stream (which is passed to the onPublish event). I think the Stream.destroy would function only for streams that are made on the server side using Stream.get(). I am not 100 % sure of this but reading the docuementation reference you mentioned above on this thread seems that this is indeed the behavior.


              So there is difference between (only in the way they are handled) server side and client side streams. You can create and 'attach' a server side stream like this :

               

              s = Stream.get("serversidestreamj");

              s.play("your client side stream ob");

              s.anyfunction; (ex : s.record() etc).

               

              and now, this 's' can be destroyed using Stream.destroy but not the client side one.

               

              Let us know if this helps. Thank you !

              • 4. Re: TypeError: Stream.destroy is not a function
                Tomas_Mirezko Community Member

                I updated my code to use Stream.get() first, but it still seems not that Stream.destroy can't be executed, but that my installation doesn't even recognize the function.

                 

                SSAS code:

                application.onUnpublish = function (client /*Client*/, stream /*Stream*/) {
                    trace("Application.onUnpublish > client " + client.userId + " stopped publishing " + stream.name);
                
                    var s = Stream.get(stream.name);
                    Stream.destroy(s);
                }
                
                

                error from admin console:

                 

                Application.onStatus > code: Application.Script.Error level: error
                Application.onStatus > + details: C:\Program Files\Adobe\Flash Media Server 4\applications\lobby2\room.asc: line 83: TypeError: Stream.destroy is not a function
                Sending error message: C:\Program Files\Adobe\Flash Media Server 4\applications\lobby2\room.asc: line 83: TypeError: Stream.destroy is not a function
                

                 

                Error happens when I reload an application and server is reading script file. Is it possible, that my installation doesn't have this method built-in? I've got FMSCore.exe File description: Adobe Flash Media Server 4.0.0.r1121

                 

                Reason why I am doing this: When I publish many client streams into one server application, they pile up (and I can see them in Admin console), I wanted to destroy and release resources for all unpublished streams. I understand that while I can see the streams in Admin console, they still exist in server's memory.

                 

                Edit #1: here is a screenshot after some clients connect and disconnect, application is empty, but streams are still reserved -- 2011-05-11 11h50_05.png

                • 5. Re: TypeError: Stream.destroy is not a function
                  mmah-umd

                  I have encountered this same problem. I am generating a new stream on the server side and want to destroy it, but the function is not recognized.

                   

                  The documentation appears to be wrong.

                  • 6. Re: TypeError: Stream.destroy is not a function
                    Apurva Udaykumar Adobe Employee

                    Hi,

                     

                    Can you paste the code snippet you're using? I tried a simple streamObj.destroy() at me end and it doesn't throw any such errors for me.

                     

                    Thanks,

                    Apurva

                    • 7. Re: TypeError: Stream.destroy is not a function
                      mmah-umd Community Member

                      I have tried this both as a static function (as shown in the documentation):

                          var s = Stream.get(streamName);

                           Stream.destroy(s);

                      "Stream.destroy is not a function"

                       

                      and as a property function for

                           s.destroy();

                      "s.destroy is not a function"