public KcpChannel(KcpOptions options, IUdpChannel channel, IKcpScheduler scheduler, Action <IFilterPipeline <IKcpSession> > handler) { base.ConfigurationSelfOptions(options); base.ConfigurationSelfFilter(handler); this.scheduler = scheduler; this.channel = channel; this.channel.ConfigurationSelfFilter((pipeline) => { pipeline.Add(this); }); this.orderOperators = BinaryOrderOperatorsFactory.GetOperators(options.Order); this.scheduler.Register(this); }
public KcpSession(uint conv, EndPoint remoteAddress, EndPoint localAddress, KcpOptions options, IUdpSession udpSession, IEventSubscriber subscriber, FilterPipeline <IKcpSession> pipeline, IKcpClosable closable) { this.Id = IdGeneratorHelper.GetNextId(); this.Conv = conv; this.LocalAddress = localAddress; this.RemoteAddress = remoteAddress; this.Order = options.Order; this.udpSession = udpSession; this.subscriber = subscriber; this.Pipeline = pipeline; this.closable = closable; var littleEndian = this.Order == BinaryOrder.LittleEndian; this.kcpKit = new KcpKit(conv, littleEndian, this.MemoryPool); this.kcpKit.SettingMtu(options.Mtu); this.kcpKit.SettingNoDelay(options.NoDelay); this.kcpKit.SettingWndSize(options.WndSize); this.kcpKit.SettingStreamMode(options.StreamMode); this.kcpKit.SettingReservedSize(options.ReservedSize); this.kcpKit.onRcv += this.OnKcpRcvEvent; this.kcpKit.onSnd += this.OnKcpSndEvent; this.kcpOperators = BinaryOrderOperatorsFactory.GetOperators(this.Order); this.rcvPool = new WrappedMemoryPool(this.MemoryPool, MemoryFlag.Kcp); this.sndPool = new WrappedMemoryPool(this.MemoryPool, MemoryFlag.Kcp); this.sndMemory = new WrappedMemory(this.MemoryPool.Rent(), MemoryFlag.Kcp); this.readerUdpMemory = new WrappedMemory(this.MemoryPool.Rent(), MemoryFlag.Udp); this.writerUdpMemory = new WrappedMemory(this.MemoryPool.Rent(), MemoryFlag.Udp); this.readerFlushDelegate = (pos, endPos) => { }; this.writerFlushDelegate = this.OnWriterComplete; this.runnableUnitDelegate = this.Update; this.subscriber.Register(this.runnableUnitDelegate); this.Pipeline.OnTransportActive(this); }
public WrappedReader(ReadOnlySequence <byte> buffer, BinaryOrder order, ReaderFlushDelegate readerFlush) { this.buffer = buffer; this.readerFlush = readerFlush; this.operators = BinaryOrderOperatorsFactory.GetOperators(order); }
public WrappedWriter(IWrappedWriter writer, BinaryOrder order, WriterFlushDelegate writerFlush) { this.writer = writer; this.writerFlush = writerFlush; this.operators = BinaryOrderOperatorsFactory.GetOperators(order); }