Ejemplo n.º 1
0
        // 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);
        }
Ejemplo n.º 2
0
        public int GetReliableMessagesAwaitingAckCount(int sequenceChannel)
        {
            int channelSlot = (int)NetDeliveryMethod.ReliableOrdered - 1 + sequenceChannel;

            NetReliableSenderChannel chan = m_sendChannels[channelSlot] as NetReliableSenderChannel;

            if (chan == null)
            {
                return(0);
            }

            return(chan.MessagesAwaitingAck);
        }
Ejemplo n.º 3
0
        // may be on user thread
        private NetSenderChannelBase CreateSenderChannel(NetMessageType tp)
        {
            NetSenderChannelBase chan;

            lock (m_sendChannels)
            {
                NetDeliveryMethod method = NetUtility.GetDeliveryMethod(tp);
                int sequenceChannel      = (int)tp - (int)method;

                int channelSlot = (int)method - 1 + sequenceChannel;
                if (m_sendChannels[channelSlot] != null)
                {
                    // 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;

                    // rebuild m_usedSendChannels
                    m_usedSendChannelsCount = 0;
                    for (int i = m_sendChannels.Length - 1; i >= 0; i--) // Reverse order so reliable messages are sent first
                    {
                        if (m_sendChannels[i] != null)
                        {
                            m_usedSendChannels[m_usedSendChannelsCount++] = m_sendChannels[i];
                        }
                    }
                }
            }

            return(chan);
        }
Ejemplo n.º 4
0
        // may be on user thread
        private NetSenderChannelBase CreateSenderChannel(NetMessageType tp)
        {
            NetSenderChannelBase chan;

            lock (m_sendChannels)
            {
                NetDeliveryMethod method = NetUtility.GetDeliveryMethod(tp);
                int sequenceChannel      = (int)tp - (int)method;

                int channelSlot = (int)method - 1 + sequenceChannel;
                if (m_sendChannels[channelSlot] != null)
                {
                    // 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), method);
                        break;

                    case NetDeliveryMethod.ReliableOrdered:
                        chan = new NetReliableSenderChannel(this, NetUtility.GetWindowSize(method));
                        break;

                    case NetDeliveryMethod.Unknown:
                    case NetDeliveryMethod.ReliableSequenced:
                    case NetDeliveryMethod.ReliableUnordered:
                    default:
                        chan = new NetReliableSenderChannel(this, NetUtility.GetWindowSize(method));
                        break;
                    }
                    m_sendChannels[channelSlot] = chan;
                }
            }

            return(chan);
        }
Ejemplo n.º 5
0
		// may be on user thread
		private NetSenderChannelBase CreateSenderChannel(NetMessageType tp)
		{
			NetSenderChannelBase chan;
			lock (m_sendChannels)
			{
				NetDeliveryMethod method = NetUtility.GetDeliveryMethod(tp);
				int sequenceChannel = (int)tp - (int)method;

				int channelSlot = (int)method - 1 + sequenceChannel;
				if (m_sendChannels[channelSlot] != null)
				{
					// 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;
		}
Ejemplo n.º 6
0
		// 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;
		}