bitmessage.NodeConnection.Connect C# (CSharp) Метод

Connect() публичный Метод

public Connect ( ) : void
Результат void
        public void Connect()
        {
            debug("Подключаюсь к " + NetworkAddress);
            _tcpClient.Connect(NetworkAddress.Host, NetworkAddress.Port);
            Send(new Version());
            Listen();
        }

Usage Example

Пример #1
0
 private void ClientsControlLoop()
 {
     // проверяю _listener, т.к. по такому же условию заканчивается цикл ListenerLoop
     while (_listener != null)
     {
         lock (_nodeConnections)
         {
             // Удаляю неподключенные клиенты
             for (int i = _nodeConnections.Count - 1; i >= 0; --i)
             {
                 if (!_nodeConnections[i].Connected)
                 {
                     _nodeConnections.RemoveAt(i);
                 }
             }
             // Довожу количество подключенных клиентов до 8
             if (_nodeConnections.Count < 8)
             {
                 var nodes = DB.Table <NetworkAddress>().OrderByDescending(x => x.TimeLastSeen).ToListAsync().Result;
                 foreach (NetworkAddress node in nodes)
                 {
                     bool find = _nodeConnections.Any(c => c.NetworkAddress.StreamHostPort == node.StreamHostPort);
                     if (!find)
                     {
                         var c = new NodeConnection(this, node);
                         try
                         {
                             //Debug.WriteLine("Пытаюсь подключиться к " + node.HostStreamPort);
                             c.Connect();
                         }
                         catch (Exception e)
                         {
                             Debug.WriteLine(node + " " + e);
                         }
                         if (c.Connected)
                         {
                             //Debug.WriteLine("Подключился к " + node.HostStreamPort);
                             _nodeConnections.Add(c);
                         }
                         if (_nodeConnections.Count >= 8)
                         {
                             break;
                         }
                     }
                 }
             }
         }
         // Сплю минуту, или если уведомят из Helper.ReadHeaderMagic
         NodeIsDisconnected.WaitOne(60 * 1000);
     }
 }
All Usage Examples Of bitmessage.NodeConnection::Connect