Esempio n. 1
0
  /** {@inheritDoc} */
  @Override
  public void close() {
    getWriteLock().lock();
    try {
      if (keepAliveJobName != null) {
        schedulingService.removeScheduledJob(keepAliveJobName);
        keepAliveJobName = null;
      }
    } finally {
      getWriteLock().unlock();
    }
    Red5.setConnectionLocal(this);
    IStreamService streamService =
        (IStreamService) getScopeService(scope, IStreamService.class, StreamService.class);
    if (streamService != null) {
      for (Map.Entry<Integer, IClientStream> entry : streams.entrySet()) {
        IClientStream stream = entry.getValue();
        if (stream != null) {
          log.debug("Closing stream: {}", stream.getStreamId());
          streamService.deleteStream(this, stream.getStreamId());
          usedStreams.decrementAndGet();
        }
      }
      streams.clear();
    }
    channels.clear();

    getWriteLock().lock();
    try {
      if (bwContext != null && getScope() != null && getScope().getContext() != null) {
        IBWControlService bwController =
            (IBWControlService) getScope().getContext().getBean(IBWControlService.KEY);
        bwController.unregisterBWControllable(bwContext);
        bwContext = null;
      }
    } finally {
      getWriteLock().unlock();
    }
    super.close();
  }
Esempio n. 2
0
 /** {@inheritDoc} */
 @Override
 public void close() {
   getWriteLock().lock();
   try {
     if (keepAliveJobName != null) {
       schedulingService.removeScheduledJob(keepAliveJobName);
       keepAliveJobName = null;
     }
   } finally {
     getWriteLock().unlock();
   }
   Red5.setConnectionLocal(this);
   IStreamService streamService =
       (IStreamService) getScopeService(scope, IStreamService.class, StreamService.class);
   if (streamService != null) {
     for (Map.Entry<Integer, IClientStream> entry : streams.entrySet()) {
       IClientStream stream = entry.getValue();
       if (stream != null) {
         log.debug("Closing stream: {}", stream.getStreamId());
         streamService.deleteStream(this, stream.getStreamId());
         usedStreams.decrementAndGet();
       }
     }
   }
   // close the base connection - disconnect scopes and unregister client
   super.close();
   // kill all the collections etc
   if (channels != null) {
     channels.clear();
     channels = null;
   } else {
     log.trace("Channels collection was null");
   }
   if (streams != null) {
     streams.clear();
     streams = null;
   } else {
     log.trace("Streams collection was null");
   }
   if (pendingCalls != null) {
     pendingCalls.clear();
     pendingCalls = null;
   } else {
     log.trace("PendingCalls collection was null");
   }
   if (deferredResults != null) {
     deferredResults.clear();
     deferredResults = null;
   } else {
     log.trace("DeferredResults collection was null");
   }
   if (pendingVideos != null) {
     pendingVideos.clear();
     pendingVideos = null;
   } else {
     log.trace("PendingVideos collection was null");
   }
   if (streamBuffers != null) {
     streamBuffers.clear();
     streamBuffers = null;
   } else {
     log.trace("StreamBuffers collection was null");
   }
 }