Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

TypeError: Stream.destroy is not a function

Explorer ,
May 09, 2011 May 09, 2011

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#W...

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.

2.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 10, 2011 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  !

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 10, 2011 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 10, 2011 May 10, 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 !

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 11, 2011 May 11, 2011

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 25, 2012 Jun 25, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 25, 2012 Jun 25, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 27, 2012 Jun 27, 2012
LATEST

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"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines