public RtmpClientConnection(IRtmpHandler handler, Socket socket) : base(null, null)
 {
     socket.ReceiveBufferSize = FluorineConfiguration.Instance.FluorineSettings.RtmpServer.RtmpTransportSettings.ReceiveBufferSize;
     socket.SendBufferSize    = FluorineConfiguration.Instance.FluorineSettings.RtmpServer.RtmpTransportSettings.SendBufferSize;
     this._handler            = handler;
     this._readBuffer         = ByteBuffer.Allocate(0x1000);
     this._readBuffer.Flip();
     this._rtmpNetworkStream = new RtmpNetworkStream(socket);
     this._state             = 1;
     base.Context.SetMode(RtmpMode.Client);
 }
 public override void Close()
 {
     lock (base.SyncRoot)
     {
         if (!(base.IsDisposed || this.IsDisconnected))
         {
             this._state = 0;
             base.Close();
             this._handler.ConnectionClosed(this);
             this._rtmpNetworkStream.Close();
         }
     }
 }
 public RtmpServerConnection(RtmpServer rtmpServer, Socket socket) : base(null, null)
 {
     this._streams       = new Dictionary <int, IClientStream>();
     this._streamBuffers = new Dictionary <int, int>();
     this._pendingVideos = new Dictionary <int, AtomicInteger>();
     this._endpoint      = rtmpServer.Endpoint;
     this._readBuffer    = ByteBuffer.Allocate(0x1000);
     this._readBuffer.Flip();
     this._rtmpServer        = rtmpServer;
     this._rtmpNetworkStream = new RtmpNetworkStream(socket);
     this._state             = 1;
     this.SetIsTunneled(false);
     this.IsTunnelingDetected = false;
 }
 public void DeferredClose()
 {
     lock (base.SyncRoot)
     {
         if (this._keepAliveJobName != null)
         {
             (base.Scope.GetService(typeof(ISchedulingService)) as ISchedulingService).RemoveScheduledJob(this._keepAliveJobName);
             this._keepAliveJobName = null;
         }
         if (!base.IsDisposed && !this.IsDisconnected)
         {
             this._state = 0;
             IStreamService scopeService = ScopeUtils.GetScopeService(base.Scope, typeof(IStreamService)) as IStreamService;
             if (scopeService != null)
             {
                 lock (((ICollection)this._streams).SyncRoot)
                 {
                     IClientStream[] array = new IClientStream[this._streams.Count];
                     this._streams.Values.CopyTo(array, 0);
                     foreach (IClientStream stream in array)
                     {
                         if (stream != null)
                         {
                             if (log.get_IsDebugEnabled())
                             {
                                 log.Debug("Closing stream: " + stream.StreamId);
                             }
                             scopeService.deleteStream(this, stream.StreamId);
                             this._streamCount--;
                         }
                     }
                     this._streams.Clear();
                 }
             }
             if (((this._bwContext != null) && (base.Scope != null)) && (base.Scope.Context != null))
             {
                 (base.Scope.GetService(typeof(IBWControlService)) as IBWControlService).UnregisterBWControllable(this._bwContext);
                 this._bwContext = null;
             }
             base.Close();
             this._rtmpServer.OnConnectionClose(this);
             this._rtmpNetworkStream.Close();
         }
     }
 }
 internal void BeginDisconnect()
 {
     if (!base.IsDisposed && !this.IsDisconnecting)
     {
         try
         {
             this._state = 2;
             ThreadPoolEx.Global.QueueUserWorkItem(new WaitCallback(this.OnDisconnectCallback), null);
         }
         catch (Exception exception)
         {
             if (log.get_IsErrorEnabled())
             {
                 log.Error("BeginDisconnect " + this.ToString(), exception);
             }
         }
     }
 }