summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Networking
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2018-11-14 00:35:36 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2018-11-14 00:35:36 -0500
commit77a7a0fe58186e49e24c41f47a2a33661afbc81c (patch)
treea1f190e7593fcfd2a1da88b47b6f51f1258e830f /src/SMAPI/Framework/Networking
parent90ecd377c88ba5a4c08a3c7e67618435358e5685 (diff)
downloadSMAPI-77a7a0fe58186e49e24c41f47a2a33661afbc81c.tar.gz
SMAPI-77a7a0fe58186e49e24c41f47a2a33661afbc81c.tar.bz2
SMAPI-77a7a0fe58186e49e24c41f47a2a33661afbc81c.zip
rework multiplayer code to allow for upcoming Galaxy client overrides (#480)
Diffstat (limited to 'src/SMAPI/Framework/Networking')
-rw-r--r--src/SMAPI/Framework/Networking/SLidgrenClient.cs19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/SMAPI/Framework/Networking/SLidgrenClient.cs b/src/SMAPI/Framework/Networking/SLidgrenClient.cs
index c05e6b76..02d9d68f 100644
--- a/src/SMAPI/Framework/Networking/SLidgrenClient.cs
+++ b/src/SMAPI/Framework/Networking/SLidgrenClient.cs
@@ -9,20 +9,21 @@ namespace StardewModdingAPI.Framework.Networking
/*********
** Properties
*********/
- /// <summary>A callback to raise when receiving a message. This receives the client instance, incoming message, and a callback to run the default logic.</summary>
- private readonly Action<SLidgrenClient, IncomingMessage, Action> OnProcessingMessage;
+ /// <summary>A callback to raise when receiving a message. This receives the incoming message, a method to send an arbitrary message, and a callback to run the default logic.</summary>
+ private readonly Action<IncomingMessage, Action<OutgoingMessage>, Action> OnProcessingMessage;
+
+ /// <summary>A callback to raise when sending a message. This receives the outgoing message, a method to send an arbitrary message, and a callback to resume the default logic.</summary>
+ private readonly Action<OutgoingMessage, Action<OutgoingMessage>, Action> OnSendingMessage;
- /// <summary>A callback to raise when sending a message. This receives the client instance, outgoing message, and a callback to run the default logic.</summary>
- private readonly Action<SLidgrenClient, OutgoingMessage, Action> OnSendingMessage;
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
/// <param name="address">The remote address being connected.</param>
- /// <param name="onProcessingMessage">A callback to raise when receiving a message. This receives the client instance, incoming message, and a callback to run the default logic.</param>
- /// <param name="onSendingMessage">A callback to raise when sending a message. This receives the client instance, outgoing message, and a callback to run the default logic.</param>
- public SLidgrenClient(string address, Action<SLidgrenClient, IncomingMessage, Action> onProcessingMessage, Action<SLidgrenClient, OutgoingMessage, Action> onSendingMessage)
+ /// <param name="onProcessingMessage">A callback to raise when receiving a message. This receives the incoming message, a method to send an arbitrary message, and a callback to run the default logic.</param>
+ /// <param name="onSendingMessage">A callback to raise when sending a message. This receives the outgoing message, a method to send an arbitrary message, and a callback to resume the default logic.</param>
+ public SLidgrenClient(string address, Action<IncomingMessage, Action<OutgoingMessage>, Action> onProcessingMessage, Action<OutgoingMessage, Action<OutgoingMessage>, Action> onSendingMessage)
: base(address)
{
this.OnProcessingMessage = onProcessingMessage;
@@ -32,7 +33,7 @@ namespace StardewModdingAPI.Framework.Networking
/// <summary>Send a message to the connected peer.</summary>
public override void sendMessage(OutgoingMessage message)
{
- this.OnSendingMessage(this, message, () => base.sendMessage(message));
+ this.OnSendingMessage(message, base.sendMessage, () => base.sendMessage(message));
}
@@ -43,7 +44,7 @@ namespace StardewModdingAPI.Framework.Networking
/// <param name="message">The message to process.</param>
protected override void processIncomingMessage(IncomingMessage message)
{
- this.OnProcessingMessage(this, message, () => base.processIncomingMessage(message));
+ this.OnProcessingMessage(message, base.sendMessage, () => base.processIncomingMessage(message));
}
}
}