private void ConnectIfNeeded() { int totalConnections = network.LocalConnections.Length; if (totalConnections < connectionCount) { for (int x = 0; x < (connectionCount - totalConnections); x++) { if (nodeList.Count != 0) { TrustedNodeInfo node = (TrustedNodeInfo)GetNode(); try { IDestination destination = node.FirstConnectableDestination; if (destination != null) { ITransport transport = destination.CreateTransport(ConnectionType.NodeConnection); network.ConnectTo(transport); } } catch (Exception ex) { Core.LoggingService.LogError("AutoconnectManager: Error while trying to connect", ex); } } else { // Nothing left, I give up! :( network.ConnectingTo -= connectingToHandler; network.NewIncomingConnection -= incomingConnectionHandler; Core.LoggingService.LogDebug("AutoconnectManager: Nothing left to connect to."); return; } } } }
private bool ConnectToPeer(BitTorrentFileTransferPeer peer) { IDestination destination = peer.Node.FirstConnectableDestination; if (destination != null) { var transport = destination.CreateTransport(ConnectionType.TransferConnection); Core.LoggingService.LogDebug("New outgoing connection"); peer.Network.ConnectTo(transport, OutgoingPeerTransportConnected); return(true); } // FIXME: Mark peer as bad! Core.LoggingService.LogError("Transfer can't connect to peer {0} - no destinations available!", peer.Node); return(false); }
void on_mnuUsersConnectTo_activate(object o, EventArgs e) { try { IDestination destination = selectedNode.FirstConnectableDestination; if (destination != null) { ITransport transport = destination.CreateTransport(ConnectionType.NodeConnection); network.ConnectTo(transport); } else { Gui.ShowErrorDialog("You cannot connect to this user."); } } catch (Exception ex) { LoggingService.LogError(ex); Gui.ShowErrorDialog(ex.Message); } }