本文整理汇总了C#中InfoHash类的典型用法代码示例。如果您正苦于以下问题:C# InfoHash类的具体用法?C# InfoHash怎么用?C# InfoHash使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InfoHash类属于命名空间,在下文中一共展示了InfoHash类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InfoHashTrackable
public InfoHashTrackable(Torrent torrent)
{
Check.Torrent(torrent);
name = torrent.Name;
infoHash = torrent.InfoHash;
}
示例2: MultipleAnnounce
public void MultipleAnnounce()
{
var announceCount = 0;
var r = new Random();
var handle = new ManualResetEvent(false);
for (var i = 0; i < 20; i++)
{
var infoHash = new InfoHash(new byte[20]);
r.NextBytes(infoHash.Hash);
var tier = new TrackerTier(new[] {uri.ToString()});
tier.Trackers[0].AnnounceComplete += delegate
{
if (++announceCount == 20)
handle.Set();
};
var id = new TrackerConnectionID(tier.Trackers[0], false, TorrentEvent.Started,
new ManualResetEvent(false));
MonoTorrent.Client.Tracker.AnnounceParameters parameters;
parameters = new MonoTorrent.Client.Tracker.AnnounceParameters(0, 0, 0, TorrentEvent.Started,
infoHash, false, new string('1', 20), "", 1411);
tier.Trackers[0].Announce(parameters, id);
}
Assert.True(handle.WaitOne(5000, true), "Some of the responses weren't received");
}
示例3: TorrentBDecoder
public TorrentBDecoder(Stream stream, Encoding encoding)
{
_reader = new BinaryReader(stream);
_streamEncoding = encoding;
_infoHash = new InfoHash();
_indicator = 0;
_inInfoMap = false;
}
示例4: PeerAEncryption
public PeerAEncryption(InfoHash InfoHash, EncryptionTypes allowedEncryption)
: base(allowedEncryption)
{
gotVerificationCallback = gotVerification;
gotPadDCallback = gotPadD;
SKEY = InfoHash;
}
示例5: PeerBEncryption
public PeerBEncryption(InfoHash[] possibleSKEYs, EncryptionTypes allowedEncryption)
: base(allowedEncryption)
{
this.possibleSKEYs = possibleSKEYs;
gotVerificationCallback = new AsyncCallback(gotVerification);
gotPadCCallback = new AsyncCallback(gotPadC);
}
示例6: PeerBEncryption
public PeerBEncryption(InfoHash[] possibleSkeYs, EncryptionTypes allowedEncryption)
: base(allowedEncryption)
{
_possibleSkeYs = possibleSkeYs;
_gotVerificationCallback = GotVerification;
_gotPadCCallback = GotPadC;
}
示例7: PeerAEncryption
public PeerAEncryption(InfoHash infoHash, EncryptionTypes allowedEncryption)
: base(allowedEncryption)
{
_gotVerificationCallback = GotVerification;
_gotPadDCallback = GotPadD;
Skey = infoHash;
}
示例8: CustomITrackable
public CustomITrackable(Torrent t)
{
// Note: I'm just storing the files, infohash and name. A typical Torrent instance
// is ~100kB in memory. A typical CustomITrackable will be ~100 bytes.
files = t.Files;
infoHash = t.InfoHash;
name = t.Name;
}
示例9: PeerAEncryption
public PeerAEncryption(InfoHash InfoHash, EncryptionTypes allowedEncryption)
: base(allowedEncryption)
{
gotVerificationCallback = new AsyncCallback(gotVerification);
gotPadDCallback = new AsyncCallback(gotPadD);
SKEY = InfoHash;
}
示例10: BeginCheckEncryption
internal static IAsyncResult BeginCheckEncryption(PeerId id, int bytesToReceive, AsyncCallback callback,
object state, InfoHash[] sKeys)
{
var result = new EncryptorAsyncResult(id, callback, state) {SKeys = sKeys};
var 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
{
var usable = CheckRc4(id);
var hasPlainText = Toolbox.HasEncryption(usable, EncryptionTypes.PlainText);
var 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);
}
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;
}
示例11: FastResume
public FastResume(InfoHash infoHash, BitField bitfield)
{
if (infoHash == null)
throw new ArgumentNullException("infoHash");
if (bitfield == null)
throw new ArgumentNullException("bitfield");
this.infoHash = infoHash;
this.bitfield = bitfield;
}
示例12: FastResume
public FastResume(InfoHash infoHash, BitField bitfield)
{
if (infoHash == null)
throw new ArgumentNullException(nameof(infoHash));
if (bitfield == null)
throw new ArgumentNullException(nameof(bitfield));
Infohash = infoHash;
Bitfield = bitfield;
}
示例13: FastResume
public FastResume(InfoHash infoHash, BitField bitfield, IEnumerable<Priority> priorities)
{
if (infoHash==null)
throw new ArgumentNullException("infoHash");
if(bitfield == null)
throw new ArgumentNullException("bitfield");
this.infoHash = infoHash;
this.bitfield = bitfield;
this.priorities = priorities.ToArray();
}
示例14: TorrentInfo
public TorrentInfo(InfoHash hash, string name, int priority, ActiveStates activestate, DownloadStates downloadstate, IEnumerable<string> labels, ulong size, ulong remaining, ulong uploaded)
{
Hash = hash;
Name = name;
Priority = priority;
ActiveState = activestate;
DownloadState = downloadstate;
Labels = new ReadOnlyCollection<string>(new List<string>(labels));
Size = size;
Remaining = remaining;
Uploaded = uploaded;
}
示例15: AnnounceParameters
public AnnounceParameters(long bytesDownloaded, long bytesUploaded, long bytesLeft,
TorrentEvent clientEvent, InfoHash infohash, bool requireEncryption,
string peerId, string ipaddress, int port)
{
BytesDownloaded = bytesDownloaded;
BytesUploaded = bytesUploaded;
BytesLeft = bytesLeft;
ClientEvent = clientEvent;
InfoHash = infohash;
RequireEncryption = requireEncryption;
PeerId = peerId;
Ipaddress = ipaddress;
Port = port;
}