public MultiplexingSocketClientProtocol(IMultiplexingSocketProtocol <TInbound, TOutbound> innerProtocol, IMessageIdGenerator idGenerator)
 {
     this.innerProtocol = innerProtocol ?? throw new ArgumentNullException(nameof(innerProtocol));
     this.idGenerator   = idGenerator ?? throw new ArgumentNullException(nameof(idGenerator));
     this.pendings      = new ConcurrentDictionary <MessageId, PendingResponse <TInbound> >();
     this.sourcePool    = new ObjectPool <PooledValueTaskSource <TInbound> >(() => { return(new PooledValueTaskSource <TInbound>()); }, 100);
     this.ScheduleRead();
 }
Example #2
0
        static async Task ProcessProtocol(IMultiplexingSocketProtocol <AddIntegerRequest, int> protocol)
        {
            while (true)
            {
                var res = await protocol.Read();

                _ = PerformAddInteger(res.Item1, res.Item2.A, res.Item2.B, protocol);
            }
        }
Example #3
0
 static async Task PerformAddInteger(MessageId id, int a, int b, IMultiplexingSocketProtocol <AddIntegerRequest, int> protocol)
 {
     var sum = a + b;
     await protocol.Write(sum, id);
 }