You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-17 07:36:32 +09:00
SendToAll added to NetServer
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
@@ -13,6 +14,38 @@ namespace Lidgren.Network
|
||||
config.AcceptIncomingConnections = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a message to all connections
|
||||
/// </summary>
|
||||
/// <param name="msg">The message to send</param>
|
||||
/// <param name="method">How to deliver the message</param>
|
||||
public void SendToAll(NetOutgoingMessage msg, NetDeliveryMethod method)
|
||||
{
|
||||
SendMessage(msg, this.Connections, method, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a message to all connections except one
|
||||
/// </summary>
|
||||
/// <param name="msg">The message to send</param>
|
||||
/// <param name="method">How to deliver the message</param>
|
||||
|
||||
|
||||
public void SendToAll(NetOutgoingMessage msg, NetConnection except, NetDeliveryMethod method)
|
||||
{
|
||||
var all = this.Connections;
|
||||
if (all.Count <= 0)
|
||||
return;
|
||||
|
||||
List<NetConnection> recipients = new List<NetConnection>(all.Count - 1);
|
||||
foreach (var conn in all)
|
||||
if (conn != except)
|
||||
recipients.Add(conn);
|
||||
|
||||
if (recipients.Count > 0)
|
||||
SendMessage(msg, recipients, method, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string that represents this object
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user