public async Task <RPCResult> GetRPCResult(uint callId) { RPCResult result = null; do { if (_idResultDict.TryRemove(callId, out var res)) { result = res; break; } if (_idRPCDict.TryGetValue(callId, out var rpc)) { if ((DateTime.Now - rpc.QueueTime) > TimeOut) { while (_idRPCDict.ContainsKey(callId)) { _idRPCDict.TryRemove(callId, out _); } result = new RPCResult { CallId = callId, Error = new TimeoutException($"RPC ({rpc.RPC.Name}) waiting time out({TimeOut}),the client will no longer wait.") }; _logger.LogError(result.Error.Message); break; } } await Task.Delay(1); } while (_defaultCancellationSource.IsCancellationRequested == false); return(result); }
private async Task <RPCResult> ReceiveRPC(CancellationToken token) { var result = new RPCResult(); var sz = new byte[4]; result.Error = await ReadFully(sz, token); if (result.Error != null) { return(result); } var buf = new byte[BinaryPrimitives.ReadUInt32BigEndian(sz)]; result.Error = await ReadFully(buf, token); if (result.Error != null) { return(result); } var resp = new ResponseHeader(); var(respLen, nb) = ProtoBufEx.DecodeVarint(buf); buf = buf[nb..];