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
Better NetSendResult when trying to send on an unconnected connection
This commit is contained in:
@@ -128,7 +128,7 @@ namespace Lidgren.Network
|
||||
if (serverConnection == null)
|
||||
{
|
||||
LogWarning("Cannot send message, no server connection!");
|
||||
return NetSendResult.Failed;
|
||||
return NetSendResult.FailedNotConnected;
|
||||
}
|
||||
|
||||
return serverConnection.SendMessage(msg, method, 0);
|
||||
@@ -143,7 +143,7 @@ namespace Lidgren.Network
|
||||
if (serverConnection == null)
|
||||
{
|
||||
LogWarning("Cannot send message, no server connection!");
|
||||
return NetSendResult.Failed;
|
||||
return NetSendResult.FailedNotConnected;
|
||||
}
|
||||
|
||||
return serverConnection.SendMessage(msg, method, sequenceChannel);
|
||||
|
||||
@@ -292,6 +292,9 @@ namespace Lidgren.Network
|
||||
// called by SendMessage() and NetPeer.SendMessage; ie. may be user thread
|
||||
internal NetSendResult EnqueueMessage(NetOutgoingMessage msg, NetDeliveryMethod method, int sequenceChannel)
|
||||
{
|
||||
if (m_status != NetConnectionStatus.Connected)
|
||||
return NetSendResult.FailedNotConnected;
|
||||
|
||||
NetMessageType tp = (NetMessageType)((int)method + sequenceChannel);
|
||||
msg.m_messageType = tp;
|
||||
|
||||
|
||||
@@ -55,6 +55,8 @@ namespace Lidgren.Network
|
||||
else
|
||||
{
|
||||
// message must be fragmented!
|
||||
if (recipient.m_status != NetConnectionStatus.Connected)
|
||||
return NetSendResult.FailedNotConnected;
|
||||
SendFragmentedMessage(msg, new NetConnection[] { recipient }, method, sequenceChannel);
|
||||
return NetSendResult.Queued; // could be different for each connection; Queued is "most true"
|
||||
}
|
||||
@@ -110,11 +112,8 @@ namespace Lidgren.Network
|
||||
continue;
|
||||
}
|
||||
NetSendResult res = conn.EnqueueMessage(msg, method, sequenceChannel);
|
||||
if (res == NetSendResult.Dropped)
|
||||
{
|
||||
LogDebug(msg + " dropped immediately due to full queues");
|
||||
if (res != NetSendResult.Queued && res != NetSendResult.Sent)
|
||||
Interlocked.Decrement(ref msg.m_recyclingCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -8,9 +8,9 @@ namespace Lidgren.Network
|
||||
public enum NetSendResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Message failed to enqueue; for example if there's no connection in place
|
||||
/// Message failed to enqueue because there is no connection
|
||||
/// </summary>
|
||||
Failed = 0,
|
||||
FailedNotConnected = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Message was immediately sent
|
||||
|
||||
Reference in New Issue
Block a user