Пример #1
0
        internal void UpdateServerConnectionCount(bool increment)
        {
            if (increment)
            {
                Interlocked.Increment(ref serverConnectionCount);
            }
            else
            {
                Interlocked.Decrement(ref serverConnectionCount);
            }

            ServerConnectionCountChanged?.Invoke(this, EventArgs.Empty);
        }
 public ProxyServerController(System.Windows.Threading.Dispatcher dispatcher)
 {
     // Guarda el dispatcher de Wpf
     Dispatcher = dispatcher;
     // Crea el objeto
     _proxyServer = new ProxyServer();
     // Añade los manejadores de eventos
     _proxyServer.BeforeRequest         += ProxyServer_BeforeRequest;
     _proxyServer.BeforeResponse        += ProxyServer_BeforeResponse;
     _proxyServer.TunnelConnectRequest  += ProxyServer_TunnelConnectRequest;
     _proxyServer.TunnelConnectResponse += ProxyServer_TunnelConnectResponse;
     // Asigna los manejadores de eventos
     _proxyServer.ClientConnectionCountChanged += (sender, args)
                                                  => ClientConnectionCountChanged?.Invoke(this,
                                                                                          new ConnectionCountEventArgs(_proxyServer.ClientConnectionCount));
     _proxyServer.ServerConnectionCountChanged += (sender, args)
                                                  => ServerConnectionCountChanged?.Invoke(this,
                                                                                          new ConnectionCountEventArgs(_proxyServer.ServerConnectionCount));
 }