private bool sendEventToTracker(TorrentInfo torrentInfo, string eventType)
{
scrapStatsUpdated = false;
currentTorrent = torrentInfo;
string urlString = getUrlString(torrentInfo, eventType);
ValueDictionary dictionary1;
try
{
Uri uri = new Uri(urlString);
TrackerResponse trackerResponse = MakeWebRequestEx(uri);
if (trackerResponse != null && trackerResponse.Dict != null)
{
dictionary1 = trackerResponse.Dict;
string failure = BEncode.String(dictionary1["failure reason"]);
if (failure.Length > 0)
{
AddLogLine("Tracker Error: " + failure);
if (!checkIgnoreFailureReason.Checked)
{
StopButton_Click(null, null);
AddLogLine("Stopped because of tracker error!!!");
return false;
}
}
else
{
foreach (string key in trackerResponse.Dict.Keys)
{
if (key != "failure reason" && key != "peers")
{
AddLogLine(key + ": " + BEncode.String(trackerResponse.Dict[key]));
}
}
if (dictionary1.Contains("interval"))
{
updateInterval(BEncode.String(dictionary1["interval"]));
}
if (dictionary1.Contains("complete") && dictionary1.Contains("incomplete"))
{
if (dictionary1.Contains("complete") && dictionary1.Contains("incomplete"))
{
updateScrapStats(BEncode.String(dictionary1["complete"]), BEncode.String(dictionary1["incomplete"]), "");
decimal leechers = BEncode.String(dictionary1["incomplete"]).ParseValidInt(0);
if (leechers == 0)
{
AddLogLine("Min number of leechers reached... setting upload speed to 0");
updateTextBox(uploadRate, "0");
chkRandUP.Checked = false;
}
}
}
if (dictionary1.Contains("peers"))
{
haveInitialPeers = true;
string text4;
if (dictionary1["peers"] is ValueString)
{
text4 = BEncode.String(dictionary1["peers"]);
Encoding encoding1 = Encoding.GetEncoding(0x6faf);
byte[] buffer1 = encoding1.GetBytes(text4);
BinaryReader reader1 = new BinaryReader(new MemoryStream(encoding1.GetBytes(text4)));
PeerList list1 = new PeerList();
for (int num1 = 0; num1 < buffer1.Length; num1 += 6)
{
list1.Add(new Peer(reader1.ReadBytes(4), reader1.ReadInt16()));
}
reader1.Close();
AddLogLine("peers: " + list1);
}
else if (dictionary1["peers"] is ValueList)
{
// text4 = "";
ValueList list2 = (ValueList)dictionary1["peers"];
PeerList list3 = new PeerList();
foreach (object obj1 in list2)
{
if (obj1 is ValueDictionary)
{
ValueDictionary dictionary2 = (ValueDictionary)obj1;
list3.Add(new Peer(BEncode.String(dictionary2["ip"]), BEncode.String(dictionary2["port"]), BEncode.String(dictionary2["peer id"])));
}
}
AddLogLine("peers: " + list3);
}
else
{
text4 = BEncode.String(dictionary1["peers"]);
AddLogLine("peers(x): " + text4);
}
}
}
return false;
}
else
{
AddLogLine("No connection in sendEventToTracker() !!!");
return false;
}
}
catch (Exception ex)
{
AddLogLine("Error in sendEventToTracker(): " + ex.Message);
return false;
}
}