Exemplo n.º 1
0
 private void stopBC()
 {
     try
     {
         this._isRunPeekQ = false;
         if (this.ipwIPPortMain != null)
         {
             if (this.ipwIPPortMain.Connected)
             {
                 this.UnregistrationFromTunnel();
                 Thread.Sleep(100);
                 this.ipwIPPortMain.Disconnect();
             }
             this.ipwIPPortMain.OnConnected -= new Ipports.OnConnectedHandler(this.ipwIPPortMain_OnConnected);
             this.ipwIPPortMain.OnDisconnected -= new Ipports.OnDisconnectedHandler(this.ipwIPPortMain_OnDisconnected);
             this.ipwIPPortMain.OnDataIn -= new Ipports.OnDataInHandler(this.ipwIPPortMain_OnDataIn);
             this.ipwIPPortMain.OnError -= new Ipports.OnErrorHandler(this.ipwIPPortMain_OnError);
             this.ipwIPPortMain.OnSSLServerAuthentication -= new Ipports.OnSSLServerAuthenticationHandler(this.ipwIPPortMain_OnSSLServerAuthentication);
             this.ipwIPPortMain.OnReadyToSend -= new Ipports.OnReadyToSendHandler(this.ipwIPPortMain_OnReadyToSend);
             this.ipwIPPortMain.Dispose();
             this.ipwIPPortMain = null;
         }
     }
     catch (Exception ex)
     {
         this.ShowError("stopBC", ex);
     }
 }
Exemplo n.º 2
0
 private void startBC()
 {
     try
     {
         this.timerMonitorFeed.Enabled = false;
         this.MarketStateBox.DisplayPushPullImage();
         if (!ApplicationInfo.IsPushMode)
         {
             this.ShowSpashForm("PULL Connecting...");
             this.InitializeFeedsWebProxy();
             this.stopBC();
             this.feedsWebProxy.Start();
         }
         else
         {
             this.ShowSpashForm("PUSH(" + Convert.ToString(ApplicationInfo.TunnelCounter + 1) + ") Connecting...");
             if (this.feedsWebProxy != null && this.feedsWebProxy.IsServiceStarted)
             {
                 this.feedsWebProxy.Stop();
             }
             if (this.ipwIPPortMain == null)
             {
                 this.ipwIPPortMain = new Ipports();
                 this.ipwIPPortMain.OnConnected += new Ipports.OnConnectedHandler(this.ipwIPPortMain_OnConnected);
                 this.ipwIPPortMain.OnDisconnected += new Ipports.OnDisconnectedHandler(this.ipwIPPortMain_OnDisconnected);
                 this.ipwIPPortMain.OnDataIn += new Ipports.OnDataInHandler(this.ipwIPPortMain_OnDataIn);
                 this.ipwIPPortMain.OnError += new Ipports.OnErrorHandler(this.ipwIPPortMain_OnError);
                 this.ipwIPPortMain.OnSSLServerAuthentication += new Ipports.OnSSLServerAuthenticationHandler(this.ipwIPPortMain_OnSSLServerAuthentication);
                 this.ipwIPPortMain.OnReadyToSend += new Ipports.OnReadyToSendHandler(this.ipwIPPortMain_OnReadyToSend);
                 this.ipwIPPortMain.Config("InBufferSize=102400");
                 if (ApplicationInfo.TunnelHosts[ApplicationInfo.TunnelCounter].EnableSSL)
                 {
                     this.ipwIPPortMain.SSLStartMode = IpportsSSLStartModes.sslImplicit;
                 }
                 else
                 {
                     this.ipwIPPortMain.SSLStartMode = IpportsSSLStartModes.sslNone;
                 }
             }
             this.ipwIPPortMain.Connected = false;
             this._isRunPeekQ = false;
             int num = 0;
             while (this._isPeekQWorking)
             {
                 num++;
                 Thread.Sleep(100);
                 if (num > 50)
                 {
                     break;
                 }
             }
             this._isRunPeekQ = true;
             if (this.ipwIPPortMain.RemoteHost != ApplicationInfo.TunnelHosts[ApplicationInfo.TunnelCounter].HostIP)
             {
                 this.ipwIPPortMain.RemoteHost = ApplicationInfo.TunnelHosts[ApplicationInfo.TunnelCounter].HostIP;
             }
             if (this.ipwIPPortMain.RemotePort != ApplicationInfo.TunnelHosts[ApplicationInfo.TunnelCounter].Port)
             {
                 this.ipwIPPortMain.RemotePort = ApplicationInfo.TunnelHosts[ApplicationInfo.TunnelCounter].Port;
             }
             this._lastEcho = DateTime.Now;
             this.ipwIPPortMain.Connected = true;
         }
         this.ShowConnectionStatus();
     }
     catch (Exception ex)
     {
         this.ShowError("StartBC", ex);
     }
     this.timerMonitorFeed.Enabled = true;
 }