You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-19 00:26:30 +09:00
Fixed intermediate status messages not being outputted using StatusChanged messages
This commit is contained in:
@@ -20,8 +20,9 @@ namespace Lidgren.Network
|
|||||||
|
|
||||||
internal NetPeer m_peer;
|
internal NetPeer m_peer;
|
||||||
internal NetPeerConfiguration m_peerConfiguration;
|
internal NetPeerConfiguration m_peerConfiguration;
|
||||||
internal NetConnectionStatus m_status;
|
internal NetConnectionStatus m_status; // actual status
|
||||||
internal NetConnectionStatus m_visibleStatus;
|
internal NetConnectionStatus m_outputtedStatus; // status that has been sent as StatusChanged message
|
||||||
|
internal NetConnectionStatus m_visibleStatus; // status visible by querying the Status property
|
||||||
internal NetEndPoint m_remoteEndPoint;
|
internal NetEndPoint m_remoteEndPoint;
|
||||||
internal NetSenderChannelBase[] m_sendChannels;
|
internal NetSenderChannelBase[] m_sendChannels;
|
||||||
internal NetReceiverChannelBase[] m_receiveChannels;
|
internal NetReceiverChannelBase[] m_receiveChannels;
|
||||||
@@ -87,6 +88,7 @@ namespace Lidgren.Network
|
|||||||
m_peer = peer;
|
m_peer = peer;
|
||||||
m_peerConfiguration = m_peer.Configuration;
|
m_peerConfiguration = m_peer.Configuration;
|
||||||
m_status = NetConnectionStatus.None;
|
m_status = NetConnectionStatus.None;
|
||||||
|
m_outputtedStatus = NetConnectionStatus.None;
|
||||||
m_visibleStatus = NetConnectionStatus.None;
|
m_visibleStatus = NetConnectionStatus.None;
|
||||||
m_remoteEndPoint = remoteEndPoint;
|
m_remoteEndPoint = remoteEndPoint;
|
||||||
m_sendChannels = new NetSenderChannelBase[NetConstants.NumTotalChannels];
|
m_sendChannels = new NetSenderChannelBase[NetConstants.NumTotalChannels];
|
||||||
@@ -115,9 +117,6 @@ namespace Lidgren.Network
|
|||||||
{
|
{
|
||||||
// user or library thread
|
// user or library thread
|
||||||
|
|
||||||
if (status == m_status)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_status = status;
|
m_status = status;
|
||||||
if (reason == null)
|
if (reason == null)
|
||||||
reason = string.Empty;
|
reason = string.Empty;
|
||||||
@@ -129,6 +128,8 @@ namespace Lidgren.Network
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_peerConfiguration.IsMessageTypeEnabled(NetIncomingMessageType.StatusChanged))
|
if (m_peerConfiguration.IsMessageTypeEnabled(NetIncomingMessageType.StatusChanged))
|
||||||
|
{
|
||||||
|
if (m_outputtedStatus != status)
|
||||||
{
|
{
|
||||||
NetIncomingMessage info = m_peer.CreateIncomingMessage(NetIncomingMessageType.StatusChanged, 4 + reason.Length + (reason.Length > 126 ? 2 : 1));
|
NetIncomingMessage info = m_peer.CreateIncomingMessage(NetIncomingMessageType.StatusChanged, 4 + reason.Length + (reason.Length > 126 ? 2 : 1));
|
||||||
info.m_senderConnection = this;
|
info.m_senderConnection = this;
|
||||||
@@ -136,10 +137,13 @@ namespace Lidgren.Network
|
|||||||
info.Write((byte)m_status);
|
info.Write((byte)m_status);
|
||||||
info.Write(reason);
|
info.Write(reason);
|
||||||
m_peer.ReleaseMessage(info);
|
m_peer.ReleaseMessage(info);
|
||||||
|
m_outputtedStatus = status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// app dont want those messages, update visible status immediately
|
// app dont want those messages, update visible status immediately
|
||||||
|
m_outputtedStatus = m_status;
|
||||||
m_visibleStatus = m_status;
|
m_visibleStatus = m_status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user