當前位置: 首頁>>代碼示例>>C#>>正文


C# PeerId.CloseConnection方法代碼示例

本文整理匯總了C#中MonoTorrent.Client.PeerId.CloseConnection方法的典型用法代碼示例。如果您正苦於以下問題:C# PeerId.CloseConnection方法的具體用法?C# PeerId.CloseConnection怎麽用?C# PeerId.CloseConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MonoTorrent.Client.PeerId的用法示例。


在下文中一共展示了PeerId.CloseConnection方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BeginCheckEncryption

        internal static IAsyncResult BeginCheckEncryption(PeerId id, int bytesToReceive, AsyncCallback callback, object state, InfoHash[] sKeys)
        {
            EncryptorAsyncResult result = new EncryptorAsyncResult(id, callback, state);
            result.SKeys = sKeys;

            IConnection c = id.Connection;
            ClientEngine.MainLoop.QueueTimeout(TimeSpan.FromSeconds(10), delegate {
                if (id.Encryptor == null || id.Decryptor == null)
                    id.CloseConnection();
                return false;
            });

            try
            {
                // If the connection is incoming, receive the handshake before
                // trying to decide what encryption to use
                if (id.Connection.IsIncoming)
                {
                    result.Buffer = new byte[bytesToReceive];
                    NetworkIO.EnqueueReceive(c, result.Buffer, 0, result.Buffer.Length, null, null, null, HandshakeReceivedCallback, result);
                }
                else
                {
                    EncryptionTypes usable = CheckRC4(id);
                    bool hasPlainText = Toolbox.HasEncryption(usable, EncryptionTypes.PlainText);
                    bool hasRC4 = Toolbox.HasEncryption(usable, EncryptionTypes.RC4Full) || Toolbox.HasEncryption(usable, EncryptionTypes.RC4Header);
                    if (id.Engine.Settings.PreferEncryption)
                    {
                        if (hasRC4)
                        {
                            result.EncSocket = new PeerAEncryption(id.TorrentManager.InfoHash, usable);
                            result.EncSocket.BeginHandshake(id.Connection, CompletedEncryptedHandshakeCallback, result);
                        }
                        else
                        {
                            result.Complete();
                        }
                    }
                    else
                    {
                        if (hasPlainText)
                        {
                            result.Complete();
                        }
                        else
                        {
                            result.EncSocket = new PeerAEncryption(id.TorrentManager.InfoHash, usable);
                            result.EncSocket.BeginHandshake(id.Connection, CompletedEncryptedHandshakeCallback, result);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result.Complete(ex);
            }
            return result;
        }
開發者ID:ArsenShnurkov,項目名稱:MonoTorrent,代碼行數:58,代碼來源:EncryptorFactory.cs

示例2: HandlePeerConnected

 public override void HandlePeerConnected(PeerId id, Direction direction)
 {
     id.CloseConnection();
 }
開發者ID:silvermcd123,項目名稱:WoWPrivateServerLauncher,代碼行數:4,代碼來源:StoppedMode.cs

示例3: HandlePeerConnected

		public override void HandlePeerConnected(PeerId id, MonoTorrent.Common.Direction direction)
		{
			id.CloseConnection();
		}
開發者ID:dontnod,項目名稱:monotorrent,代碼行數:4,代碼來源:StoppingMode.cs

示例4: HandlePeerConnected

 public override void HandlePeerConnected(PeerId id, Direction direction)
 {
     if (!ShouldConnect(id))
         id.CloseConnection();
     base.HandlePeerConnected(id, direction);
 }
開發者ID:rajkosto,項目名稱:DayZeroLauncher,代碼行數:6,代碼來源:DownloadMode.cs


注:本文中的MonoTorrent.Client.PeerId.CloseConnection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。