public void SendNotInterested() { if (!IsInterestedSent) { return; } ConsoleLogger.WriteLn(this, "-> not interested"); SendBytes(PeerEncoder.EncodeNotInterested()); IsInterestedSent = false; }
public void SendInterested() { if (IsInterestedSent) { return; } ConsoleLogger.WriteLn(this, "-> interested"); SendBytes(PeerEncoder.EncodeInterested()); IsInterestedSent = true; }
public void SendUnchoke() { if (!IsChokeSent) { return; } ConsoleLogger.WriteLn(this, "-> unchoke"); SendBytes(PeerEncoder.EncodeUnchoke()); IsChokeSent = false; }
public void SendChoke() { if (IsChokeSent) { return; } ConsoleLogger.WriteLn(this, "-> choke"); SendBytes(PeerEncoder.EncodeChoke()); IsChokeSent = true; }
public void SendKeepAlive() { if (LastKeepAlive > DateTime.UtcNow.AddSeconds(-30)) { return; } ConsoleLogger.WriteLn(this, "-> keep alive"); SendBytes(PeerEncoder.EncodeKeepAlive()); LastKeepAlive = DateTime.UtcNow; }
private void SendHandshake() { if (IsHandshakeSent) { return; } ConsoleLogger.WriteLn(this, "-> handshake"); SendBytes(PeerEncoder.EncodeHandshake(Torrent.Infohash, LocalId)); IsHandshakeSent = true; }
public void SendCancel(int index, int begin, int length) { ConsoleLogger.WriteLn(this, "-> cancel"); SendBytes(PeerEncoder.EncodeCancel(index, begin, length)); }
public void SendPiece(int index, int begin, byte[] data) { ConsoleLogger.WriteLn(this, "-> piece " + index + ", " + begin + ", " + data.Length); SendBytes(PeerEncoder.EncodePiece(index, begin, data)); Uploaded += data.Length; }
public void SendRequest(int index, int begin, int length) { ConsoleLogger.WriteLn(this, "-> request " + index + ", " + begin + ", " + length); SendBytes(PeerEncoder.EncodeRequest(index, begin, length)); }
public void SendBitfield(bool[] isPieceDownloaded) { ConsoleLogger.WriteLn(this, "-> bitfield " + string.Join("", isPieceDownloaded.Select(x => x ? 1 : 0))); SendBytes(PeerEncoder.EncodeBitfield(isPieceDownloaded)); }
public void SendHave(int index) { ConsoleLogger.WriteLn(this, "-> have " + index); SendBytes(PeerEncoder.EncodeHave(index)); }