// Web request/response private void SendWebRequest(string subUrl, List <string> values) { string requestUrl = "http://%host:%port/%suburl".Replace("%host", m_host).Replace("%port", m_port).Replace("%suburl", subUrl); Dictionary <string, string> headers = new Dictionary <string, string>(); headers.Add("server_name", m_configData.server_name); string body = ""; foreach (string line in values) { body += line; body += "\n"; } byte[] data = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(body + m_configData.server_password)); StringBuilder sBuilder = new StringBuilder(); for (int i = 0; i < data.Length; i++) { sBuilder.Append(data[i].ToString("x2")); } headers.Add("salt", sBuilder.ToString()); m_webRequests.EnqueuePost(requestUrl, body, (code, response) => ReceiveWebResponse(code, response), this, headers); }
public static void SendPayload(string payload) { var headers = new Dictionary <string, string> { { "User-Agent", $"Oxide/{OxideMod.Version} ({Environment.OSVersion}; {Environment.OSVersion.Platform})" } }; Webrequests.EnqueuePost(url, Uri.EscapeUriString(payload), (code, response) => { }, null, headers); }
public object OnUserChat(IPlayer player, string message) { webRequest.EnqueuePost(ingoingWebhookUrl, JsonConvert.SerializeObject(new Request(channelName, integrationName, string.Format(_("SlackMessage"), player.Id, player.Name, message), integrationIcon)), (code, response) => HandlePostCallback(code, response), this); return(null); }
// Web request/response private void SendWebRequest(string subUrl, string body, Action <int, string> callback) { string requestUrl = "http://%host:%port/api/%server_name/%suburl".Replace("%host", m_host).Replace("%port", m_port).Replace("%suburl", subUrl).Replace("%server_name", m_configData.server_name); Dictionary <string, string> headers = new Dictionary <string, string>(); byte[] data = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(body + m_configData.server_password)); StringBuilder sBuilder = new StringBuilder(); for (int i = 0; i < data.Length; i++) { sBuilder.Append(data[i].ToString("x2")); } headers.Add("salt", sBuilder.ToString()); m_webRequests.EnqueuePost(requestUrl, body, callback, this, headers); }
private static void SubmitNextReport() { if (queuedReports.Count < 1) return; var queued_report = queuedReports[0]; submittingReports = true; Action<int, string> on_request_complete = (code, response) => { if (code == 200) { queuedReports.RemoveAt(0); submittingReports = false; SubmitNextReport(); } else { timers.Once(5f, SubmitNextReport); } }; webrequests.EnqueuePost(url, queued_report.Body, on_request_complete, null, queued_report.Headers); }
private static void SubmitNextReport() { if (QueuedReports.Count < 1) { return; } var queuedReport = QueuedReports[0]; submittingReports = true; Webrequests.EnqueuePost(Url, queuedReport.Body, (code, response) => { if (code == 200) { QueuedReports.RemoveAt(0); submittingReports = false; SubmitNextReport(); } else { Timers.Once(5f, SubmitNextReport); } }, null, queuedReport.Headers); }
private void ExamplePostRequest(Player player, string command, string[] args) { webRequests.EnqueuePost("http://reign-of-kings.net/server/319/vote/confirm/", "", (code, response) => WebRequestCallback(code, response, player), this); //webRequests.EnqueueGet("http://reign-of-kings.net/server/319/vote/confirm/", (code, response) => WebRequestCallback(code, response, player), this); }