Пример #1
0
        private NetReceiverChannelBase CreateReceiverChannel(NetMessageType tp)
        {
            m_peer.VerifyNetworkThread();

            // create receiver channel
            NetReceiverChannelBase chan;
            NetDeliveryMethod      method = NetUtility.GetDeliveryMethod(tp);

            switch (method)
            {
            case NetDeliveryMethod.Unreliable:
                chan = new NetUnreliableUnorderedReceiver(this);
                break;

            case NetDeliveryMethod.ReliableOrdered:
                chan = new NetReliableOrderedReceiver(this, NetConstants.ReliableOrderedWindowSize);
                break;

            case NetDeliveryMethod.UnreliableSequenced:
                chan = new NetUnreliableSequencedReceiver(this);
                break;

            case NetDeliveryMethod.ReliableUnordered:
                chan = new NetReliableUnorderedReceiver(this, NetConstants.ReliableOrderedWindowSize);
                break;

            case NetDeliveryMethod.ReliableSequenced:
                chan = new NetReliableSequencedReceiver(this, NetConstants.ReliableSequencedWindowSize);
                break;

            case NetDeliveryMethod.Unknown:
            default:
                throw new NetException("Unhandled NetDeliveryMethod!");
            }

            int channelSlot = (int)tp - 1;

            NetException.Assert(m_receiveChannels[channelSlot] == null);
            m_receiveChannels[channelSlot] = chan;

            return(chan);
        }
Пример #2
0
		private NetReceiverChannelBase CreateReceiverChannel(NetMessageType tp)
		{
			m_peer.VerifyNetworkThread();

			// create receiver channel
			NetReceiverChannelBase chan;
			NetDeliveryMethod method = NetUtility.GetDeliveryMethod(tp);
			switch (method)
			{
				case NetDeliveryMethod.Unreliable:
					chan = new NetUnreliableUnorderedReceiver(this);
					break;
				case NetDeliveryMethod.ReliableOrdered:
					chan = new NetReliableOrderedReceiver(this, NetConstants.ReliableOrderedWindowSize);
					break;
				case NetDeliveryMethod.UnreliableSequenced:
					chan = new NetUnreliableSequencedReceiver(this);
					break;
				case NetDeliveryMethod.ReliableUnordered:
					chan = new NetReliableUnorderedReceiver(this, NetConstants.ReliableOrderedWindowSize);
					break;
				case NetDeliveryMethod.ReliableSequenced:
					chan = new NetReliableSequencedReceiver(this, NetConstants.ReliableSequencedWindowSize);
					break;
				default:
					throw new NetException("Unhandled NetDeliveryMethod!");
			}

			int channelSlot = (int)tp - 1;
			NetException.Assert(m_receiveChannels[channelSlot] == null);
			m_receiveChannels[channelSlot] = chan;

			return chan;
		}