예제 #1
0
 public static void Decode(
     this RailPacketIncoming packet,
     RailResource resource,
     RailBitBuffer buffer)
 {
     packet.Decode(resource, resource, resource, buffer);
 }
예제 #2
0
        /// <summary>
        ///     Records acknowledging information for the packet.
        /// </summary>
        protected virtual void ProcessPacket(RailPacketIncoming packetBase, Tick localTick)
        {
            RemoteClock.UpdateLatest(packetBase.SenderTick);
            foreach (RailEvent evnt in FilterIncomingEvents(packetBase.Events))
            {
                ProcessEvent(evnt);
            }

            CleanOutgoingEvents(packetBase.LastAckEventId);
        }
예제 #3
0
        private static void DecodeHeader(RailPacketIncoming packet, RailBitBuffer buffer)
        {
            // Read: [LocalTick]
            packet.SenderTick = buffer.ReadTick();

            // Read: [LastAckTick]
            packet.LastAckTick = buffer.ReadTick();

            // Read: [AckReliableEventId]
            packet.LastAckEventId = buffer.ReadSequenceId();
        }
예제 #4
0
        private static void DecodeEvents(
            RailPacketIncoming packet,
            IRailEventConstruction eventCreator,
            RailBitBuffer buffer)
        {
            IEnumerable <RailEvent> decoded = buffer.UnpackAll(
                buf => RailEvent.Decode(
                    eventCreator,
                    eventCreator.EventTypeCompressor,
                    buf,
                    packet.SenderTick));

            foreach (RailEvent evnt in decoded)
            {
                packet.Events.Add(evnt);
            }
        }
예제 #5
0
        public static void Decode(
            this RailPacketIncoming packet,
            IRailCommandConstruction commandCreator,
            IRailStateConstruction stateCreator,
            IRailEventConstruction eventCreator,
            RailBitBuffer buffer)
        {
            // Read: [Header]
            DecodeHeader(packet, buffer);

            // Read: [Events] (Early Pack)
            DecodeEvents(packet, eventCreator, buffer);

            // Read: [Payload]
            packet.DecodePayload(commandCreator, stateCreator, buffer);

            // Read: [Events] (Fill Pack)
            DecodeEvents(packet, eventCreator, buffer);
        }
예제 #6
0
        protected RailPeer(
            RailResource resource,
            IRailNetPeer netPeer,
            ExternalEntityVisibility visibility,
            uint remoteSendRate,
            RailInterpreter interpreter,
            RailPacketIncoming reusableIncoming,
            RailPacketOutgoing reusableOutgoing) : base(resource, visibility, netPeer)
        {
            Resource         = resource;
            RemoteClock      = new RailClock(remoteSendRate);
            this.interpreter = interpreter;

            outgoingEvents        = new Queue <RailEvent>();
            this.reusableIncoming = reusableIncoming;
            this.reusableOutgoing = reusableOutgoing;
            lastQueuedEventId     = SequenceId.Start.Next;
            eventHistory          = new RailHistory(RailConfig.HISTORY_CHUNKS);

            LocalTick = Tick.START;
            netPeer.PayloadReceived += OnPayloadReceived;
        }