public override async Task <PluginData> OnUpdateDataRequest() { var pluginData = new PluginData(); string host = PluginSettings.GetData <string>("Host"); string loginToken = PluginSettings.GetData <string>("Cookie"); if (string.IsNullOrEmpty(host) || string.IsNullOrEmpty(loginToken)) { pluginData.SetData("IsSuccess", false); } else { string result = await QBittorrentHelper.GetCurrentStats(host, ""); if (string.IsNullOrEmpty(result)) { pluginData.SetData("IsSuccess", false); } else { JObject jObject = JObject.Parse(result); pluginData.SetData("CurrentDownload", jObject["dl_info_speed"].Value <int>()); pluginData.SetData("CurrentUpload", jObject["up_info_speed"].Value <int>()); pluginData.SetData("IsSuccess", true); } } return(pluginData); }
public override Task <PluginData> OnUpdateDataRequest() { var pluginData = new PluginData(); string host = PluginSettings.GetData <string>("Host"); int port = PluginSettings.GetData <int>("Port"); if (string.IsNullOrEmpty(host) || port < 255 || port > 65535) { pluginData.SetData("IsSuccess", false); } else { var result = RTorrentHelper.GetCurrentStats(host, port); if (result == null) { pluginData.SetData("IsSuccess", false); } else { pluginData.SetData("CurrentDownload", result.Item1); pluginData.SetData("CurrentUpload", result.Item2); pluginData.SetData("IsSuccess", true); } } return(Task.FromResult(pluginData)); }
private void PingServer() { string host = PluginSettings.GetData <string>("Host"); int port = PluginSettings.GetData <int>("Port"); if (string.IsNullOrEmpty(host) || port == 0) { CachedData.RemoveKey("ServerStatus"); } else if (Uri.CheckHostName(host) == UriHostNameType.Unknown) { CachedData.RemoveKey("ServerStatus"); } else { CachedData.SetData("ServerStatus", new MinecraftServerHelper().PingServer(host, port)); } }