コード例 #1
0
        public NetMessenger(NetMessengerConfig config)
        {
            this.config            = config;
            receivedPackets        = new ConcurrentQueue <NetInboundPacket>();
            delayedReceivedPackets = new ConcurrentQueue <DelayedInboundPacket>();
            ignoredConnections     = new ConcurrentDictionary <IPEndPoint, IgnoredConnection>();
            trackedConnections     = new ConcurrentDictionary <IPEndPoint, TrackedConnection>();
            lastIgnoreLengths      = new ConcurrentDictionary <IPEndPoint, int>();

            Channels       = new ConcurrentDictionary <ushort, RemoteChannel>();
            StateChannels  = new ConcurrentDictionary <ushort, StateRemoteChannel>();
            inboundRemotes = new ConcurrentQueue <InboundRemote>();

            Connections = new NetConnectionDictionary();

            packetLossRandom = new Random();

            GlobalChannel = new CoreRemoteChannel(this, 0);
            HiddenChannel = new CoreRemoteChannel(this, 1);
        }
コード例 #2
0
        public NetConnection(IPEndPoint endPoint, NetMessenger messenger)
        {
            this.messenger = messenger;
            EndPoint       = endPoint;

            Stats = new NetConnectionStats();

            handledPacketIds                   = new ConcurrentUniqueList <ushort>();
            reliableOutboundPacketQueue        = new ConcurrentDictionary <ushort, ReliablePacket>();
            reliableOrderedOutboundPacketQueue = new ConcurrentQueue <ReliablePacket>();
            packetChunkQueue                   = new ConcurrentHashSet <NetOutboundPacket>();
            Partials = new ConcurrentDictionary <ushort, NetMessenger.PartialPacket>();

            config = messenger.GetBaseConfig();

            // Ensure we don't immediatly time out or send a ping request
            lastPingRequest  = NetTime.Now + 1000;
            lastPingResponse = NetTime.Now;

            PacketSendRate = 79;
        }