Skip to main content
Participating Frequently
May 9, 2011
Question

TypeError: Stream.destroy is not a function

  • May 9, 2011
  • 1 reply
  • 2936 views

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-7e42.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.

    This topic has been closed for replies.

    1 reply

    Nikhil_Kalyan
    Participating Frequently
    May 10, 2011

    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  !

    Participating Frequently
    May 10, 2011

    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

    Nikhil_Kalyan
    Participating Frequently
    May 11, 2011

    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 !