Skip to main content
Participant
January 10, 2007
Question

how to close correctly?

  • January 10, 2007
  • 1 reply
  • 256 views
i have application that i'm the administrator make connection and publish stream
and few (the members) are also make connection to me and play stream
i want sometimes to close their connection
i close their stream and connection
by simple code:
ns.close()
nc.close()
the connection indeed closed
but in the communication app inspector
i notice that their stream still remain
and changed to type idle and also the event applicatin.disconnected
in the asc file didn't occured
when the user by himself close the web page
or go to another web page
the stream disappeard from the communication app inspector
and also the event applicatin.disconnected happened
what is the way that i should close the member connection
so the stream will disappear from the communication app inspector
and not be idle and also the event applicatin.disconnected will happen
    This topic has been closed for replies.

    1 reply

    January 10, 2007
    Use application.disconnect(clientObj) in the server-sided code to remove a client the 'hard way' from your FMS

    OR

    call a function on the client that closes their own connection to your FMS.
    Make sure you WAIT for the event that occurs after your issue the netstream.close() function.

    e.g.

    Flash client-code:

    // track the status of your netstream object

    my_netstream.onStatus = function(infoObject:Object) {
    trace("NetStream.onStatus called: ("+getTimer()+" ms)");
    // output all variables
    for (var prop in infoObject) {
    trace("\t"+prop+":\t"+infoObject[prop]);
    }
    if (infoObject.code == "NetStream.Unpublish.Success") {
    // ok our publishing stream has been stopped
    if (bool_stop_now == true) {
    // we had to stop ; close our connection to the FMS server
    my_netconnection.close();
    }
    }
    };

    // client-side function ; call this one from the server
    my_netconnection.close_from_server = function () {
    bool_stop_now = true;
    my_netstream.close();
    }


    The reason you might want to wait for events to occur is that you might close the connection too fast to your FMS ; the netstream might not be closed correctly in time resulting in an idling stream on your FMS.