SendModPacket (Server) added

This commit is contained in:
EntenKoeniq 2021-11-23 23:17:47 +01:00
parent 48cbff2f11
commit f6a49fe87f
2 changed files with 32 additions and 0 deletions

View File

@ -83,5 +83,22 @@ namespace CoopServer
packet.PacketToNetOutGoingMessage(outgoingMessage); packet.PacketToNetOutGoingMessage(outgoingMessage);
Server.MainNetServer.SendMessage(outgoingMessage, userConnection, NetDeliveryMethod.ReliableOrdered, 0); Server.MainNetServer.SendMessage(outgoingMessage, userConnection, NetDeliveryMethod.ReliableOrdered, 0);
} }
public void SendModPacket(string mod, byte customID, byte[] bytes)
{
NetConnection userConnection = Server.MainNetServer.Connections.Find(x => x.RemoteUniqueIdentifier == ID);
NetOutgoingMessage outgoingMessage = Server.MainNetServer.CreateMessage();
new ModPacket()
{
ID = -1,
Target = 0,
Mod = mod,
CustomPacketID = customID,
Bytes = bytes
}.PacketToNetOutGoingMessage(outgoingMessage);
Server.MainNetServer.SendMessage(outgoingMessage, userConnection, NetDeliveryMethod.ReliableOrdered, 0);
Server.MainNetServer.FlushSendQueue();
}
} }
} }

View File

@ -151,6 +151,21 @@ namespace CoopServer
#endregion #endregion
#region FUNCTIONS #region FUNCTIONS
public static void SendModPacketToAll(string mod, byte customID, byte[] bytes)
{
NetOutgoingMessage outgoingMessage = Server.MainNetServer.CreateMessage();
new ModPacket()
{
ID = -1,
Target = 0,
Mod = mod,
CustomPacketID = customID,
Bytes = bytes
}.PacketToNetOutGoingMessage(outgoingMessage);
Server.MainNetServer.SendMessage(outgoingMessage, Server.MainNetServer.Connections, NetDeliveryMethod.ReliableOrdered, 0);
Server.MainNetServer.FlushSendQueue();
}
public static void SendNativeCallToAll(ulong hash, params object[] args) public static void SendNativeCallToAll(ulong hash, params object[] args)
{ {
if (Server.MainNetServer.ConnectionsCount == 0) if (Server.MainNetServer.ConnectionsCount == 0)