You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-18 16:16:35 +09:00
Made CreateSenderChannel() reentrant
This commit is contained in:
@@ -332,27 +332,38 @@ namespace Lidgren.Network
|
|||||||
private NetSenderChannelBase CreateSenderChannel(NetMessageType tp)
|
private NetSenderChannelBase CreateSenderChannel(NetMessageType tp)
|
||||||
{
|
{
|
||||||
NetSenderChannelBase chan;
|
NetSenderChannelBase chan;
|
||||||
NetDeliveryMethod method = NetUtility.GetDeliveryMethod(tp);
|
lock (m_sendChannels)
|
||||||
int sequenceChannel = (int)tp - (int)method;
|
|
||||||
switch (method)
|
|
||||||
{
|
{
|
||||||
case NetDeliveryMethod.Unreliable:
|
NetDeliveryMethod method = NetUtility.GetDeliveryMethod(tp);
|
||||||
case NetDeliveryMethod.UnreliableSequenced:
|
int sequenceChannel = (int)tp - (int)method;
|
||||||
chan = new NetUnreliableSenderChannel(this, NetUtility.GetWindowSize(method));
|
|
||||||
break;
|
|
||||||
case NetDeliveryMethod.ReliableOrdered:
|
|
||||||
chan = new NetReliableSenderChannel(this, NetUtility.GetWindowSize(method));
|
|
||||||
break;
|
|
||||||
case NetDeliveryMethod.ReliableSequenced:
|
|
||||||
case NetDeliveryMethod.ReliableUnordered:
|
|
||||||
default:
|
|
||||||
chan = new NetReliableSenderChannel(this, NetUtility.GetWindowSize(method));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int channelSlot = (int)method - 1 + sequenceChannel;
|
int channelSlot = (int)method - 1 + sequenceChannel;
|
||||||
NetException.Assert(m_sendChannels[channelSlot] == null);
|
if (m_sendChannels[channelSlot] != null)
|
||||||
m_sendChannels[channelSlot] = chan;
|
{
|
||||||
|
// we were pre-empted by another call to this method
|
||||||
|
chan = m_sendChannels[channelSlot];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (method)
|
||||||
|
{
|
||||||
|
case NetDeliveryMethod.Unreliable:
|
||||||
|
case NetDeliveryMethod.UnreliableSequenced:
|
||||||
|
chan = new NetUnreliableSenderChannel(this, NetUtility.GetWindowSize(method));
|
||||||
|
break;
|
||||||
|
case NetDeliveryMethod.ReliableOrdered:
|
||||||
|
chan = new NetReliableSenderChannel(this, NetUtility.GetWindowSize(method));
|
||||||
|
break;
|
||||||
|
case NetDeliveryMethod.ReliableSequenced:
|
||||||
|
case NetDeliveryMethod.ReliableUnordered:
|
||||||
|
default:
|
||||||
|
chan = new NetReliableSenderChannel(this, NetUtility.GetWindowSize(method));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
m_sendChannels[channelSlot] = chan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return chan;
|
return chan;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user