Пример #1
0
        private void CloseSink(HTTPSession ss)
        {
            bool err = false;
            string erraddr = "";

            ss.CancelAllEvents();
            lock (TagQueue)
            {
                KeepAliveTimer.Remove(this.GetHashCode());

                if (TagQueue.Count > 0)
                {
                    OpenSource.Utilities.EventLogger.Log(this, System.Diagnostics.EventLogEntryType.Information, "Switching Pipeline Modes [" + ss.GetHashCode().ToString() + "]");
                    _PIPELINE = false;
                    if (!ReceivedFirstResponse)
                    {
                        erraddr = ((StateData)TagQueue.Peek()).Dest.ToString();
                    }
                }

                if (!ReceivedFirstResponse)
                {
                    OpenSource.Utilities.EventLogger.Log(this, System.Diagnostics.EventLogEntryType.Error, "Server[" + erraddr + "] closed socket without answering");
                    err = true;
                }

                while (TagQueue.Count > 0)
                {
                    StateData sd = (StateData)TagQueue.Dequeue();
                    if (!err)
                    {
                        HTTPRequest TR = new HTTPRequest();
                        TR.ProxySetting = ProxySetting;
                        TR._PIPELINE = true;
                        if (this.OnSniff != null) TR.OnSniff += new HTTPRequest.SniffHandler(NonPipelinedSniffSink);
                        if (this.OnSniffPacket != null) TR.OnSniffPacket += new HTTPRequest.RequestHandler(NonPipelinedSniffPacketSink);
                        TR.OnResponse += new HTTPRequest.RequestHandler(NonPipelinedResponseSink);
                        this.NotPipelinedTable[TR] = TR;
                        TR.PipelineRequest(sd.Dest, sd.Request, sd.Tag);
                    }
                    else
                    {
                        if (OnResponse != null) OnResponse(this, null, sd.Tag);

                    }
                }
                s = null;
            }
        }
 /// <summary>
 /// This method simply tells the session to unwire all of the callbacks
 /// and allows the <see cref="HTTPSession"/> object to properly get
 /// disposed because the callback events are strong references to
 /// this class.
 /// <para>
 /// This method is supposed to be called after the 
 /// <see cref="MediaServerDevice.WebSession_OnStreamDone"/> 
 /// method executes in scenarios where the session actually gets closed.
 /// </para>
 /// </summary>
 /// <param name="TheSession"></param>
 private void WebSession_OnSessionClosed(HTTPSession TheSession)
 {
     TheSession.CancelAllEvents();
 }