Skip to content

Commit

Permalink
Discord: Allow messages to adjust http web request state, e.g. for se…
Browse files Browse the repository at this point in the history
…tting custom headers
  • Loading branch information
UnknownShadow200 committed Sep 19, 2024
1 parent b16544a commit c0cf4c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions MCGalaxy/Modules/Relay/Discord/DiscordApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ protected override void HandleNext() {

string data = Json.SerialiseObject(msg.ToJson());
HttpUtil.SetRequestData(req, Encoding.UTF8.GetBytes(data));
msg.OnRequest(req);
res = req.GetResponse();

string resp = HttpUtil.GetResponseText(res);
Expand Down
4 changes: 4 additions & 0 deletions MCGalaxy/Modules/Relay/Discord/DiscordMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ permissions and limitations under the Licenses.
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using MCGalaxy.Config;

Expand All @@ -40,6 +41,9 @@ public abstract class DiscordApiMessage
/// <summary> Attempts to combine this message with a prior message to reduce API calls </summary>
public virtual bool CombineWith(DiscordApiMessage prior) { return false; }


/// <summary> Optionally adjusts the request to send to Discord </summary>
public virtual void OnRequest(HttpWebRequest req) { }

/// <summary> Processes the response received from Discord </summary>
public virtual void ProcessResponse(string response) { }
Expand Down

0 comments on commit c0cf4c6

Please sign in to comment.