public ReliableMessageChannel() { config = ReliableConfig.DefaultConfig(); config.TransmitPacketCallback = (buffer, size) => { TransmitCallback(buffer, size); }; config.ProcessPacketCallback = processPacket; config.AckPacketCallback = ackPacket; sendBuffer = new SequenceBuffer <BufferedPacket>(256); receiveBuffer = new SequenceBuffer <BufferedPacket>(256); ackBuffer = new SequenceBuffer <OutgoingPacketSet>(256); time = DateTime.Now.GetTotalSeconds(); lastBufferFlush = -1.0; lastMessageSend = 0.0; this.packetController = new ReliablePacketController(config, time); this.congestionDisableInterval = 5.0; this.sequence = 0; this.nextReceive = 0; this.oldestUnacked = 0; }
public ReliablePacketController(ReliableConfig config, double time) { this.config = config; this.time = time; sentPackets = new SequenceBuffer <SentPacketData>(config.SentPacketBufferSize); receivedPackets = new SequenceBuffer <ReceivedPacketData>(config.ReceivedPacketBufferSize); fragmentReassembly = new SequenceBuffer <FragmentReassemblyData>(config.FragmentReassemblyBufferSize); }
public UnreliableOrderedMessageChannel() { config = ReliableConfig.DefaultConfig(); config.TransmitPacketCallback = (buffer, size) => { TransmitCallback(buffer, size); }; config.ProcessPacketCallback = processPacket; packetController = new ReliablePacketController(config, DateTime.Now.GetTotalSeconds()); }
public UnreliableMessageChannel() { receiveBuffer = new SequenceBuffer <ReceivedPacketData>(256); config = ReliableConfig.DefaultConfig(); config.TransmitPacketCallback = delegate(byte[] buffer, int size) { TransmitCallback(buffer, size); }; config.ProcessPacketCallback = delegate(ushort seq, byte[] buffer, int size) { if (!receiveBuffer.Exists(seq)) { receiveBuffer.Insert(seq); ReceiveCallback(ChannelID, buffer, size); } }; packetController = new ReliablePacketController(config, DateTime.Now.GetTotalSeconds()); }
public static ReliableConfig DefaultConfig() { ReliableConfig reliableConfig = new ReliableConfig(); reliableConfig.Name = "endpoint"; reliableConfig.MaxPacketSize = 65536; reliableConfig.FragmentThreshold = 1024; reliableConfig.MaxFragments = 16; reliableConfig.FragmentSize = 1024; reliableConfig.SentPacketBufferSize = 256; reliableConfig.ReceivedPacketBufferSize = 256; reliableConfig.FragmentReassemblyBufferSize = 64; reliableConfig.RTTSmoothFactor = 0.25f; reliableConfig.PacketLossSmoothingFactor = 0.1f; reliableConfig.BandwidthSmoothingFactor = 0.1f; reliableConfig.PacketHeaderSize = 28; return(reliableConfig); }