diff --git a/GeneralMods/ModdedUtilitiesNetworking/Class1.cs b/GeneralMods/ModdedUtilitiesNetworking/Class1.cs
index aed6092b..16ceb69a 100644
--- a/GeneralMods/ModdedUtilitiesNetworking/Class1.cs
+++ b/GeneralMods/ModdedUtilitiesNetworking/Class1.cs
@@ -73,7 +73,7 @@ namespace ModdedUtilitiesNetworking
if (e.KeyPressed==Microsoft.Xna.Framework.Input.Keys.K)
{
- multiplayer.sendModInfoReturnVoid(Framework.Features.Stardew.MessageFeatures.FSTRING_SendHUDMessageWithIcon, MessagesExtentions.HUDMessageIconIdentifier, new HUDMessage("My love is like fire",1));
+ multiplayer.sendModInfoReturnVoid(Framework.Features.Stardew.MessageFeatures.FSTRING_SendHUDMessageWithIcon, MessagesExtentions.HUDMessageIconIdentifier, new HUDMessage("My love is like fire",1),Framework.Enums.MessageTypes.messageTypes.SendToAll);
}
}
diff --git a/GeneralMods/ModdedUtilitiesNetworking/Framework/Clients/CustomLidgrenClient.cs b/GeneralMods/ModdedUtilitiesNetworking/Framework/Clients/CustomLidgrenClient.cs
index fa105f9f..10296127 100644
--- a/GeneralMods/ModdedUtilitiesNetworking/Framework/Clients/CustomLidgrenClient.cs
+++ b/GeneralMods/ModdedUtilitiesNetworking/Framework/Clients/CustomLidgrenClient.cs
@@ -30,6 +30,11 @@ namespace ModdedUtilitiesNetworking.Framework.Clients
return "";
}
+ public virtual NetClient getClient()
+ {
+ return this.client;
+ }
+
protected override string getHostUserName()
{
return this.client.ServerConnection.RemoteEndPoint.Address.ToString();
@@ -144,19 +149,19 @@ namespace ModdedUtilitiesNetworking.Framework.Clients
{
using (BinaryWriter writer = new BinaryWriter((Stream)bufferWriteStream))
{
- if (message.MessageType != 20)
+ if (message.MessageType <20)
{
message.Write(writer);
}
else
{
- OutgoingMessageBase.WriteFromMessage(message, writer);
+ OutgoingMessageBase.WriteFromMessage(message, writer);
}
}
}
- int num = (int)this.client.SendMessage(message1, NetDeliveryMethod.ReliableOrdered);
+ int num = (int)this.client.SendMessage(message1, NetDeliveryMethod.ReliableOrdered);
if (num == (int)NetSendResult.Sent)
{
ModCore.monitor.Log("DONE Writing message from client!");
@@ -187,9 +192,8 @@ namespace ModdedUtilitiesNetworking.Framework.Clients
base.processIncomingMessage(message);
//Packet signiture for functions that return nothing.
- if (message.MessageType == 20)
+ if (message.MessageType == Enums.MessageTypes.SendOneWay || message.MessageType == Enums.MessageTypes.SendToAll)
{
-
object[] obj = message.Reader.ReadModdedInfoPacket();
string functionName = (string)obj[0];
string classType = (string)obj[1];
@@ -198,8 +202,6 @@ namespace ModdedUtilitiesNetworking.Framework.Clients
return;
}
-
-
//message.Reader.ReadChar();
//Write Binary ententions reader
diff --git a/GeneralMods/ModdedUtilitiesNetworking/Framework/CustomMultiplayer.cs b/GeneralMods/ModdedUtilitiesNetworking/Framework/CustomMultiplayer.cs
index e5f428cb..9a0f1940 100644
--- a/GeneralMods/ModdedUtilitiesNetworking/Framework/CustomMultiplayer.cs
+++ b/GeneralMods/ModdedUtilitiesNetworking/Framework/CustomMultiplayer.cs
@@ -36,26 +36,28 @@ namespace ModdedUtilitiesNetworking.Framework
///
public void sendMessage(OutgoingMessage message)
{
- if (Game1.server != null)
- {
- foreach (long peerId in (IEnumerable)Game1.otherFarmers.Keys)
+ if (Game1.server != null)
{
- Game1.server.sendMessage(peerId, message);
+ foreach (long peerId in (IEnumerable)Game1.otherFarmers.Keys)
+ {
+ Game1.server.sendMessage(peerId, message);
+ }
}
- }
- if (Game1.client != null)
- {
- if (Game1.client is CustomLidgrenClient) {
- (Game1.client as CustomLidgrenClient).sendMessage(message);
- return;
- }
- if (Game1.client is CustomGalaxyClient)
+ if (Game1.client != null)
{
- (Game1.client as CustomGalaxyClient).sendMessage(message);
- return;
- }
- ModCore.monitor.Log("Error sending server message!!!");
+ if (Game1.client is CustomLidgrenClient)
+ {
+ (Game1.client as CustomLidgrenClient).sendMessage(message);
+ return;
+ }
+ if (Game1.client is CustomGalaxyClient)
+ {
+ (Game1.client as CustomGalaxyClient).sendMessage(message);
+ return;
+ }
+ ModCore.monitor.Log("Error sending server message!!!");
+
}
}
@@ -84,15 +86,21 @@ namespace ModdedUtilitiesNetworking.Framework
///
///
///
- public OutgoingMessage sendOutGoingMessageReturnVoid(string functionName, string objectParametersType, object data, Farmer source)
+ public OutgoingMessage sendOutGoingMessageReturnVoid(string functionName, string objectParametersType, object data, Farmer source,Enums.MessageTypes.messageTypes sendingInfo)
{
- OutgoingMessage message = new OutgoingMessage((byte)20, source, makeDataArray(functionName, objectParametersType, data));
+ byte bite = new byte();
+ if (sendingInfo == Enums.MessageTypes.messageTypes.SendOneWay) bite = Enums.MessageTypes.SendOneWay;
+ if (sendingInfo == Enums.MessageTypes.messageTypes.SendToAll) bite = Enums.MessageTypes.SendToAll;
+ OutgoingMessage message = new OutgoingMessage(bite, source, makeDataArray(functionName, objectParametersType, data));
return message;
}
- public OutgoingMessage sendOutGoingMessageReturnVoid(string functionName, Type objectParametersType, object data, Farmer source)
+ public OutgoingMessage sendOutGoingMessageReturnVoid(string functionName, Type objectParametersType, object data, Farmer source, Enums.MessageTypes.messageTypes sendingInfo)
{
- OutgoingMessage message = new OutgoingMessage((byte)20, source, makeDataArray(functionName, objectParametersType.ToString(), data));
+ byte bite=new byte();
+ if (sendingInfo == Enums.MessageTypes.messageTypes.SendOneWay) bite = Enums.MessageTypes.SendOneWay;
+ if (sendingInfo == Enums.MessageTypes.messageTypes.SendToAll) bite = Enums.MessageTypes.SendToAll;
+ OutgoingMessage message = new OutgoingMessage(bite, source, makeDataArray(functionName, objectParametersType.ToString(), data));
return message;
}
@@ -116,11 +124,11 @@ namespace ModdedUtilitiesNetworking.Framework
///
///
///
- public void sendModInfoReturnVoid(string uniqueID,Type classType,object data)
+ public void sendModInfoReturnVoid(string uniqueID,Type classType,object data, Enums.MessageTypes.messageTypes sendingInfo)
{
Farmer f = Game1.player;
- OutgoingMessage message =ModCore.multiplayer.sendOutGoingMessageReturnVoid(uniqueID, classType, data, f);
+ OutgoingMessage message =ModCore.multiplayer.sendOutGoingMessageReturnVoid(uniqueID, classType, data, f, sendingInfo);
ModCore.multiplayer.sendMessage(message);
}
@@ -132,11 +140,11 @@ namespace ModdedUtilitiesNetworking.Framework
///
///
///
- public void sendModInfoReturnVoid(string uniqueID, string classType, object data)
+ public void sendModInfoReturnVoid(string uniqueID, string classType, object data, Enums.MessageTypes.messageTypes sendingInfo)
{
Farmer f = Game1.player;
- OutgoingMessage message = ModCore.multiplayer.sendOutGoingMessageReturnVoid(uniqueID, classType, data, f);
+ OutgoingMessage message = ModCore.multiplayer.sendOutGoingMessageReturnVoid(uniqueID, classType, data, f,sendingInfo);
ModCore.multiplayer.sendMessage(message);
}
diff --git a/GeneralMods/ModdedUtilitiesNetworking/Framework/Enums/MessageTypes.cs b/GeneralMods/ModdedUtilitiesNetworking/Framework/Enums/MessageTypes.cs
new file mode 100644
index 00000000..238b871b
--- /dev/null
+++ b/GeneralMods/ModdedUtilitiesNetworking/Framework/Enums/MessageTypes.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ModdedUtilitiesNetworking.Framework.Enums
+{
+ public class MessageTypes
+ {
+ public enum messageTypes
+ {
+ SendOneWay,
+ SendToAll,
+ SendToSpecific
+ }
+
+
+ ///
+ /// Sends a one way message. If sent from server it sends to all clients.
+ /// If sent from a client it sends only to the server.
+ ///
+ public const int SendOneWay = 20;
+
+ ///
+ /// Sends the message to all clients and the server.
+ ///
+ public const int SendToAll = 21;
+
+ ///
+ /// Unused.
+ ///
+ public const int SendToSpecific = 22;
+
+ }
+}
diff --git a/GeneralMods/ModdedUtilitiesNetworking/Framework/Servers/CustomGameServer.cs b/GeneralMods/ModdedUtilitiesNetworking/Framework/Servers/CustomGameServer.cs
index 587ecbcc..a282ab0d 100644
--- a/GeneralMods/ModdedUtilitiesNetworking/Framework/Servers/CustomGameServer.cs
+++ b/GeneralMods/ModdedUtilitiesNetworking/Framework/Servers/CustomGameServer.cs
@@ -379,20 +379,44 @@ namespace ModdedUtilitiesNetworking.Framework.Servers
case 5:
this.warpFarmer(message.SourceFarmer, message.Reader.ReadInt16(), message.Reader.ReadInt16(), message.Reader.ReadString(), (int)message.Reader.ReadByte() == 1);
break;
- case 20:
+ case Enums.MessageTypes.SendOneWay:
object[] obj = message.Reader.ReadModdedInfoPacket();
string functionName = (string)obj[0];
string classType = (string)obj[1];
object actualObject = ModCore.processTypesToRead(message.Reader, classType);
ModCore.processVoidFunction(functionName, actualObject);
break;
+ case Enums.MessageTypes.SendToAll:
+ object[] obj2 = message.Reader.ReadModdedInfoPacket();
+ string functionName2 = (string)obj2[0];
+ string classType2 = (string)obj2[1];
+ object actualObject2 = ModCore.processTypesToRead(message.Reader, classType2);
+ ModCore.processVoidFunction(functionName2, actualObject2);
+ this.rebroadcastClientMessageToAllClients(message);
+ break;
default:
ModCore.multiplayer.processIncomingMessage(message);
break;
}
+ //this.rebroadcastClientMessage(message);
+ }
+ ///
+ /// Takes an incoming client message and sends it back to all clients to process.
+ ///
+ ///
+ private void rebroadcastClientMessageToAllClients(IncomingMessage message)
+ {
+ byte messageType = Enums.MessageTypes.SendOneWay;
+ Farmer f = Game1.player;
+ object data = message.Data.Clone();
+ OutgoingMessage message1 = new OutgoingMessage(messageType, f, data);
+ foreach (long peerId in (IEnumerable)Game1.otherFarmers.Keys)
+ {
+ ModCore.monitor.Log("RESEND MESSAGE TO CLIENT!!!", StardewModdingAPI.LogLevel.Alert);
+ this.sendMessage(peerId, message1);
+ }
- this.rebroadcastClientMessage(message);
}
private void rebroadcastClientMessage(IncomingMessage message)
diff --git a/GeneralMods/ModdedUtilitiesNetworking/Framework/Servers/CustomLidgrenServer.cs b/GeneralMods/ModdedUtilitiesNetworking/Framework/Servers/CustomLidgrenServer.cs
index b02f0a54..0cf65b95 100644
--- a/GeneralMods/ModdedUtilitiesNetworking/Framework/Servers/CustomLidgrenServer.cs
+++ b/GeneralMods/ModdedUtilitiesNetworking/Framework/Servers/CustomLidgrenServer.cs
@@ -197,7 +197,7 @@ namespace ModdedUtilitiesNetworking.Framework.Servers
using (NetBufferWriteStream bufferWriteStream = new NetBufferWriteStream((NetBuffer)message1))
{
using (BinaryWriter writer = new BinaryWriter((Stream)bufferWriteStream)) {
- if (message.MessageType != 20)
+ if (message.MessageType < 20)
{
message.Write(writer);
}
diff --git a/GeneralMods/ModdedUtilitiesNetworking/ModdedUtilitiesNetworking.csproj b/GeneralMods/ModdedUtilitiesNetworking/ModdedUtilitiesNetworking.csproj
index 322543ab..dc8a0e4d 100644
--- a/GeneralMods/ModdedUtilitiesNetworking/ModdedUtilitiesNetworking.csproj
+++ b/GeneralMods/ModdedUtilitiesNetworking/ModdedUtilitiesNetworking.csproj
@@ -54,6 +54,7 @@
+