|
@@ -223,11 +223,12 @@ namespace Microsoft.Xna.Framework.Net
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// Sends data using PacketWriter.
|
|
|
+ /// Sends data using PacketWriter to specific recipients.
|
|
|
/// </summary>
|
|
|
/// <param name="data">The data to send.</param>
|
|
|
/// <param name="options">Send options.</param>
|
|
|
- public void SendData(PacketWriter data, SendDataOptions options)
|
|
|
+ /// <param name="recipients">The gamers to send to.</param>
|
|
|
+ public void SendData(PacketWriter data, SendDataOptions options, IEnumerable<NetworkGamer> recipients)
|
|
|
{
|
|
|
if (data == null)
|
|
|
throw new ArgumentNullException(nameof(data), "PacketWriter cannot be null.");
|
|
@@ -235,26 +236,23 @@ namespace Microsoft.Xna.Framework.Net
|
|
|
if (!Enum.IsDefined(typeof(SendDataOptions), options))
|
|
|
throw new ArgumentOutOfRangeException(nameof(options), "Invalid send data option.");
|
|
|
|
|
|
+ if (recipients == null)
|
|
|
+ throw new ArgumentNullException(nameof(recipients));
|
|
|
+
|
|
|
byte[] serializedData = data.GetData();
|
|
|
- SendDataInternal(serializedData, options, session.AllGamers);
|
|
|
+ SendDataInternal(serializedData, options, recipients);
|
|
|
+
|
|
|
+ data.Position = 0; // Reset position after sending
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// Sends data using PacketWriter to specific recipients.
|
|
|
+ /// Sends data using PacketWriter.
|
|
|
/// </summary>
|
|
|
/// <param name="data">The data to send.</param>
|
|
|
/// <param name="options">Send options.</param>
|
|
|
- /// <param name="recipients">The gamers to send to.</param>
|
|
|
- public void SendData(PacketWriter data, SendDataOptions options, IEnumerable<NetworkGamer> recipients)
|
|
|
+ public void SendData(PacketWriter data, SendDataOptions options)
|
|
|
{
|
|
|
- if (data == null)
|
|
|
- throw new ArgumentNullException(nameof(data), "PacketWriter cannot be null.");
|
|
|
-
|
|
|
- if (recipients == null)
|
|
|
- throw new ArgumentNullException(nameof(recipients));
|
|
|
-
|
|
|
- byte[] serializedData = data.GetData();
|
|
|
- SendDataInternal(serializedData, options, recipients);
|
|
|
+ SendData(data, options, session.AllGamers);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|