internal void ProcessFreshConnection(PeerId id)
{
// If we have too many open connections, close the connection
if (OpenConnections > this.MaxOpenConnections)
{
CleanupSocket (id, "Too many connections");
return;
}
try
{
id.ProcessingQueue = true;
// Increase the count of the "open" connections
EncryptorFactory.BeginCheckEncryption(id, 0, this.endCheckEncryptionCallback, id);
id.TorrentManager.Peers.ConnectedPeers.Add(id);
id.WhenConnected = DateTime.Now;
// Baseline the time the last block was received
id.LastBlockReceived = DateTime.Now;
}
catch (Exception)
{
id.TorrentManager.RaiseConnectionAttemptFailed(
new PeerConnectionFailedEventArgs(id.TorrentManager, id.Peer, Direction.Outgoing, "ProcessFreshConnection: failed to encrypt"));
id.Connection.Dispose();
id.Connection = null;
}
}