public static void Decode( this RailPacketIncoming packet, RailResource resource, RailBitBuffer buffer) { packet.Decode(resource, resource, resource, buffer); }
/// <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); }
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(); }
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); } }
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); }
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; }