コード例 #1
0
ファイル: DefaultProxy.cs プロジェクト: schlndh/netool
 public void Close()
 {
     if (!closed)
     {
         closed = true;
         clientChannel.Close();
         clientChannel.UnbindAllEvents(clientHandlers);
         serverChannel.Close();
         serverChannel.UnbindAllEvents(serverHandlers);
         OnChannelClosed();
     }
 }
コード例 #2
0
ファイル: DefaultProxy.cs プロジェクト: schlndh/netool
        public DefaultProxyChannel(IClient client, IServerChannel srvChannel)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (srvChannel == null)
            {
                throw new ArgumentNullException("srvChannel");
            }
            clientHandlers = new IChannelExtensions.ChannelHandlers
            {
                ErrorOccured     = errorOccuredHandler,
                ChannelClosed    = channelClosedHandler,
                ChannelReplaced  = client_ChannelReplaced,
                RequestSent      = client_RequestSent,
                ResponseReceived = client_ResponseReceived,
            };

            serverHandlers = new IChannelExtensions.ChannelHandlers
            {
                ErrorOccured    = errorOccuredHandler,
                ChannelClosed   = channelClosedHandler,
                ChannelReplaced = server_ChannelReplaced,
                RequestReceived = server_RequestReceived,
                ResponseSent    = server_ResponseSent,
            };
            Exception clientException        = null;
            EventHandler <Exception> handler = delegate(object sender, Exception e)
            {
                clientException = e;
            };

            client.ErrorOccured += handler;
            clientChannel        = client.Start();
            client.ErrorOccured -= handler;
            if (clientChannel != null)
            {
                clientChannel.BindAllEvents(clientHandlers);
                serverChannel = srvChannel;
                serverChannel.BindAllEvents(serverHandlers);
            }
            else
            {
                srvChannel.Close();
                if (clientException != null)
                {
                    throw clientException;
                }
                throw new DefaultProxyException("Unable to start a client channel.");
            }
        }
コード例 #3
0
 /// <inheritdoc/>
 public void Close()
 {
     innerChannel.Close();
 }
コード例 #4
0
 public void Close()
 {
     channel.Close();
 }