// may be on user thread private NetSenderChannelBase CreateSenderChannel(NetMessageType tp) { NetSenderChannelBase chan; NetDeliveryMethod method = NetUtility.GetDeliveryMethod(tp); int sequenceChannel = (int)tp - (int)method; 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; } int channelSlot = (int)method - 1 + sequenceChannel; NetException.Assert(m_sendChannels[channelSlot] == null); m_sendChannels[channelSlot] = chan; return(chan); }
/// <summary> /// Zero windowSize indicates that the channel is not yet instantiated (used) /// Negative freeWindowSlots means this amount of messages are currently queued but delayed due to closed window /// </summary> public void GetSendQueueInfo(NetDeliveryMethod method, int sequenceChannel, out int windowSize, out int freeWindowSlots) { int channelSlot = (int)method - 1 + sequenceChannel; var chan = m_sendChannels[channelSlot]; if (chan == null) { windowSize = NetUtility.GetWindowSize(method); freeWindowSlots = windowSize; return; } windowSize = chan.WindowSize; freeWindowSlots = chan.GetAllowedSends() - chan.m_queuedSends.Count; return; }