コード例 #1
0
        public void Dispose()
        {
            StopListening(null);

            if (_pipe != null)
            {
                _pipe.Dispose();
                _pipe = null;
            }

            //TODO: Cancel listeners.
        }
コード例 #2
0
        ////////////////////////////////////////////////////////////

        public void CloseStaleConnections()
        {
            ArrayList _activeConnections = new ArrayList();

            foreach (Object obj in _list)
            {
                PipeConnection _pipe = (PipeConnection)obj;

                if (_pipe.IsConnectionStale() == true)
                {
                    DBG.Info(null, "Disposing of stale connection");
                    _pipe.Dispose();
                    _pipe = null;
                }
                else
                {
                    _activeConnections.Add(_pipe);
                }
            }

            _list = _activeConnections;
        }
コード例 #3
0
        private void ServerMain()
        {
            PipeConnection pipe = _pipe;

            _pipe = null;

            // Signal the guy to start waiting again... (w/ new event and endpoint)
            _event.Set();

            try
            {
                //TODO close the connection on a timeout
                //TODO if no activity for Nnnn milliseconds
                while (true)
                {
                    pipe.BeginReadMessage();
                    ITransportHeaders headers = pipe.ReadHeaders();
                    headers["__CustomErrorsEnabled"] = false;

                    Stream request = pipe.ReadStream();
                    pipe.EndReadMessage();

                    ServerChannelSinkStack stack = new ServerChannelSinkStack();
                    stack.Push(_transportSink, null);

                    IMessage          responseMsg;
                    ITransportHeaders responseHeaders;
                    Stream            responseStream;

                    ServerProcessing processing = _transportSink.NextChannelSink.ProcessMessage(stack,
                                                                                                null,
                                                                                                headers,
                                                                                                request,
                                                                                                out responseMsg,
                                                                                                out responseHeaders,
                                                                                                out responseStream);

                    // handle response
                    switch (processing)
                    {
                    case ServerProcessing.Complete:
                        // Send the response. Call completed synchronously.
                        stack.Pop(_transportSink);
                        WriteClientResponse(pipe, responseHeaders, responseStream);
                        break;

                    case ServerProcessing.OneWay:
                        break;

                    case ServerProcessing.Async:
                        stack.StoreAndDispatch(_transportSink, null);
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                DBG.Info(null, "Terminating client connection: " + e.Message);
                WriteExceptionResponse(pipe, e.ToString());
            }
            finally
            {
                if (pipe != null)
                {
                    pipe.Dispose();
                }
            }
        }