当前位置: 首页>>代码示例>>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;未经允许,请勿转载。