You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-16 23:26:32 +09:00
Various ArgumentNullExceptions added
This commit is contained in:
@@ -620,6 +620,9 @@ namespace Lidgren.Network
|
|||||||
|
|
||||||
public bool SendMessage(NetOutgoingMessage msg, NetDeliveryMethod method, int sequenceChannel)
|
public bool SendMessage(NetOutgoingMessage msg, NetDeliveryMethod method, int sequenceChannel)
|
||||||
{
|
{
|
||||||
|
if (msg == null)
|
||||||
|
throw new ArgumentNullException("msg");
|
||||||
|
|
||||||
NetException.Assert(msg.m_libType == NetMessageLibraryType.Error, "Use SendLibrary() instead!");
|
NetException.Assert(msg.m_libType == NetMessageLibraryType.Error, "Use SendLibrary() instead!");
|
||||||
|
|
||||||
if (msg.IsSent)
|
if (msg.IsSent)
|
||||||
|
|||||||
@@ -73,6 +73,9 @@ namespace Lidgren.Network
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ReadAllProperties(object target, BindingFlags flags)
|
public void ReadAllProperties(object target, BindingFlags flags)
|
||||||
{
|
{
|
||||||
|
if (target == null)
|
||||||
|
throw new ArgumentNullException("target");
|
||||||
|
|
||||||
if (target == null)
|
if (target == null)
|
||||||
return;
|
return;
|
||||||
Type tp = target.GetType();
|
Type tp = target.GetType();
|
||||||
|
|||||||
@@ -106,6 +106,9 @@ namespace Lidgren.Network
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Recycle(NetIncomingMessage msg)
|
public void Recycle(NetIncomingMessage msg)
|
||||||
{
|
{
|
||||||
|
if (msg == null)
|
||||||
|
throw new ArgumentNullException("msg");
|
||||||
|
|
||||||
if (msg.m_status != NetIncomingMessageReleaseStatus.ReleasedToApplication)
|
if (msg.m_status != NetIncomingMessageReleaseStatus.ReleasedToApplication)
|
||||||
throw new NetException("Message not under application control; recycled more than once?");
|
throw new NetException("Message not under application control; recycled more than once?");
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,9 @@ namespace Lidgren.Network
|
|||||||
|
|
||||||
public NetPeer(NetPeerConfiguration configuration)
|
public NetPeer(NetPeerConfiguration configuration)
|
||||||
{
|
{
|
||||||
|
if (configuration == null)
|
||||||
|
throw new ArgumentNullException("configuration");
|
||||||
|
|
||||||
m_status = NetPeerStatus.NotRunning;
|
m_status = NetPeerStatus.NotRunning;
|
||||||
m_configuration = configuration;
|
m_configuration = configuration;
|
||||||
m_connections = new List<NetConnection>(m_configuration.MaximumConnections);
|
m_connections = new List<NetConnection>(m_configuration.MaximumConnections);
|
||||||
@@ -109,6 +112,9 @@ namespace Lidgren.Network
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public NetConnection GetConnection(IPEndPoint remoteEndPoint)
|
public NetConnection GetConnection(IPEndPoint remoteEndPoint)
|
||||||
{
|
{
|
||||||
|
if (remoteEndPoint == null)
|
||||||
|
throw new ArgumentNullException("remoteEndPoint");
|
||||||
|
|
||||||
NetConnection retval;
|
NetConnection retval;
|
||||||
if (m_connectionLookup.TryGetValue(remoteEndPoint, out retval))
|
if (m_connectionLookup.TryGetValue(remoteEndPoint, out retval))
|
||||||
return retval;
|
return retval;
|
||||||
@@ -219,6 +225,9 @@ namespace Lidgren.Network
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual NetConnection Connect(IPEndPoint remoteEndpoint, NetOutgoingMessage approvalMessage)
|
public virtual NetConnection Connect(IPEndPoint remoteEndpoint, NetOutgoingMessage approvalMessage)
|
||||||
{
|
{
|
||||||
|
if (remoteEndpoint == null)
|
||||||
|
throw new ArgumentNullException("remoteEndpoint");
|
||||||
|
|
||||||
lock (m_connections)
|
lock (m_connections)
|
||||||
{
|
{
|
||||||
if (m_status == NetPeerStatus.NotRunning)
|
if (m_status == NetPeerStatus.NotRunning)
|
||||||
@@ -259,6 +268,11 @@ namespace Lidgren.Network
|
|||||||
/// <returns>True if the message was queued for delivery, else false</returns>
|
/// <returns>True if the message was queued for delivery, else false</returns>
|
||||||
public bool SendMessage(NetOutgoingMessage msg, NetConnection recipient, NetDeliveryMethod deliveryMethod, int channel)
|
public bool SendMessage(NetOutgoingMessage msg, NetConnection recipient, NetDeliveryMethod deliveryMethod, int channel)
|
||||||
{
|
{
|
||||||
|
if (msg == null)
|
||||||
|
throw new ArgumentNullException("msg");
|
||||||
|
if (recipient == null)
|
||||||
|
throw new ArgumentNullException("recipient");
|
||||||
|
|
||||||
if (msg.IsSent)
|
if (msg.IsSent)
|
||||||
throw new NetException("Message has already been sent!");
|
throw new NetException("Message has already been sent!");
|
||||||
if (channel < 0 || channel > 63)
|
if (channel < 0 || channel > 63)
|
||||||
@@ -278,6 +292,11 @@ namespace Lidgren.Network
|
|||||||
/// <param name="channel">Delivery channel (0-31)</param>
|
/// <param name="channel">Delivery channel (0-31)</param>
|
||||||
public bool SendMessage(NetOutgoingMessage msg, IEnumerable<NetConnection> recipients, NetDeliveryMethod deliveryMethod, int sequenceChannel)
|
public bool SendMessage(NetOutgoingMessage msg, IEnumerable<NetConnection> recipients, NetDeliveryMethod deliveryMethod, int sequenceChannel)
|
||||||
{
|
{
|
||||||
|
if (msg == null)
|
||||||
|
throw new ArgumentNullException("msg");
|
||||||
|
if (recipients == null)
|
||||||
|
throw new ArgumentNullException("recipients");
|
||||||
|
|
||||||
if (msg.IsSent)
|
if (msg.IsSent)
|
||||||
throw new NetException("Message has already been sent!");
|
throw new NetException("Message has already been sent!");
|
||||||
if (sequenceChannel < 0 || sequenceChannel > NetConstants.NetChannelsPerDeliveryMethod)
|
if (sequenceChannel < 0 || sequenceChannel > NetConstants.NetChannelsPerDeliveryMethod)
|
||||||
@@ -307,6 +326,11 @@ namespace Lidgren.Network
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void SendUnconnectedMessage(NetOutgoingMessage msg, string host, int port)
|
public void SendUnconnectedMessage(NetOutgoingMessage msg, string host, int port)
|
||||||
{
|
{
|
||||||
|
if (msg == null)
|
||||||
|
throw new ArgumentNullException("msg");
|
||||||
|
if (host == null)
|
||||||
|
throw new ArgumentNullException("host");
|
||||||
|
|
||||||
IPAddress adr = NetUtility.Resolve(host);
|
IPAddress adr = NetUtility.Resolve(host);
|
||||||
if (adr == null)
|
if (adr == null)
|
||||||
throw new NetException("Failed to resolve " + host);
|
throw new NetException("Failed to resolve " + host);
|
||||||
@@ -319,6 +343,11 @@ namespace Lidgren.Network
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void SendUnconnectedMessage(NetOutgoingMessage msg, IPEndPoint recipient)
|
public void SendUnconnectedMessage(NetOutgoingMessage msg, IPEndPoint recipient)
|
||||||
{
|
{
|
||||||
|
if (msg == null)
|
||||||
|
throw new ArgumentNullException("msg");
|
||||||
|
if (recipient == null)
|
||||||
|
throw new ArgumentNullException("recipient");
|
||||||
|
|
||||||
if (msg.IsSent)
|
if (msg.IsSent)
|
||||||
throw new NetException("Message has already been sent!");
|
throw new NetException("Message has already been sent!");
|
||||||
msg.m_wasSent = true;
|
msg.m_wasSent = true;
|
||||||
@@ -331,6 +360,10 @@ namespace Lidgren.Network
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void SendUnconnectedMessage(NetOutgoingMessage msg, IEnumerable<IPEndPoint> recipients)
|
public void SendUnconnectedMessage(NetOutgoingMessage msg, IEnumerable<IPEndPoint> recipients)
|
||||||
{
|
{
|
||||||
|
if (msg == null)
|
||||||
|
throw new ArgumentNullException("msg");
|
||||||
|
if (recipients == null)
|
||||||
|
throw new ArgumentNullException("recipients");
|
||||||
if (msg.IsSent)
|
if (msg.IsSent)
|
||||||
throw new NetException("Message has already been sent!");
|
throw new NetException("Message has already been sent!");
|
||||||
msg.m_wasSent = true;
|
msg.m_wasSent = true;
|
||||||
@@ -344,9 +377,12 @@ namespace Lidgren.Network
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void SendDiscoveryResponse(NetOutgoingMessage msg, IPEndPoint recipient)
|
public void SendDiscoveryResponse(NetOutgoingMessage msg, IPEndPoint recipient)
|
||||||
{
|
{
|
||||||
|
if (recipient == null)
|
||||||
|
throw new ArgumentNullException("recipient");
|
||||||
|
|
||||||
if (msg == null)
|
if (msg == null)
|
||||||
msg = CreateMessage(0);
|
msg = CreateMessage(0);
|
||||||
if (msg.IsSent)
|
else if (msg.IsSent)
|
||||||
throw new NetException("Message has already been sent!");
|
throw new NetException("Message has already been sent!");
|
||||||
|
|
||||||
msg.m_libType = NetMessageLibraryType.DiscoveryResponse;
|
msg.m_libType = NetMessageLibraryType.DiscoveryResponse;
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ namespace Lidgren.Network
|
|||||||
|
|
||||||
public void Disconnect(NetConnection connection, string byeMessage)
|
public void Disconnect(NetConnection connection, string byeMessage)
|
||||||
{
|
{
|
||||||
|
if (connection == null)
|
||||||
|
throw new ArgumentNullException("connection");
|
||||||
|
|
||||||
connection.Disconnect(byeMessage);
|
connection.Disconnect(byeMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user