public void close ( ) { //log.debug("Stream close: {}", publishedName); if ( closed . compareAndSet ( false , true ) ) { if ( livePipe != null ) { livePipe . unsubscribe ( ( IProvider ) this ) ; } // if we have a recording listener, inform that this stream is done if ( recordingListener != null ) { sendRecordStopNotify ( ) ; notifyRecordingStop ( ) ; // inform the listener to finish and close recordingListener . get ( ) . stop ( ) ; } sendPublishStopNotify ( ) ; // TODO: can we send the client something to make sure he stops sending data? if ( connMsgOut != null ) { connMsgOut . unsubscribe ( this ) ; } notifyBroadcastClose ( ) ; // clear the listener after all the notifications have been sent if ( recordingListener != null ) { recordingListener . clear ( ) ; } // clear listeners if ( ! listeners . isEmpty ( ) ) { listeners . clear ( ) ; } // deregister with jmx unregisterJMX ( ) ; setState ( StreamState . CLOSED ) ; } }
Closes stream unsubscribes provides sends stoppage notifications and broadcast close notification .