示例#1
0
        public virtual async Task <object> InvokeAsync(string method, object[] args)
        {
            var packet = new Packet
            {
                Method    = method,
                Arguments = args,
                RequestId = Guid.NewGuid()
            };
            await _tcpClient.SendAsync(packet);

            var requestId = _semaphoreProvider.Create();

            return(await _semaphoreProvider.GetTaskById(requestId));
        }
示例#2
0
        public virtual async Task <object> InvokeAsync(Guid sessionId, string method, object[] args)
        {
            var requestId = _semaphoreProvider.Create();
            await _tcpClient.SendAsync(new Packet
            {
                SessionId = _serverIdentifier.GetIdentifier(),
                Type      = PacketType.Forward,
                RequestId = requestId,
                Arguments = new object[]
                {
                    new Packet
                    {
                        Type      = PacketType.Request,
                        SessionId = sessionId,
                        Method    = method,
                        Arguments = args,
                        RequestId = Guid.NewGuid()
                    }
                }
            });

            return(_semaphoreProvider.GetTaskById(requestId));
        }