Esempio n. 1
0
        public SimpleRpcClient(IPAddress ip, int port)
        {
            ServerIP   = ip;
            ServerPort = port;

            _transport = new TcpTransport(this, ServerIP, ServerPort);
            _requestMessageConstructor = new RequestMessageConstructor();
            _syncQueryContext          = new SyncQueryContext();
            _asyncQueryContext         = new AsyncQueryContext();
        }
Esempio n. 2
0
        private FrameData QueryInternal(RequestMessageConstructor rmc)
        {
            _syncQueryContext.Reset(rmc.MessageId);
            _transport.Send(rmc.SendBuffer, rmc.MessageByteCount);
            var receiveData = _syncQueryContext.WaitForResult(rmc.MessageId, NetworkSettings.ReceiveTimeout).Result;

            if (receiveData == null)
            {
                _transport.Close();
                throw new RpcException("SimpleRpcClient Query failed,time is out");
            }

            if (rmc.ThrowIfErrorResponseCode)
            {
                if (receiveData.StateCode != (byte)ResponseCode.OK)
                {
                    throw new RpcException("SimpleRpcClient Query failed,error code:" + receiveData.StateCode);
                }
            }

            return(receiveData);
        }
Esempio n. 3
0
        private FrameData QueryInternal(RequestMessageConstructor rmc)
        {
            _syncQueryContext.Reset(rmc.MessageId);
            _transport.Send(rmc.SendBuffer, rmc.MessageByteCount);
            var receiveData = _syncQueryContext.WaitForResult(rmc.MessageId, NetworkSettings.ReceiveTimeout);

            if (receiveData == null)
            {
                _transport.Close();
                throw new RpcException("SimpleRpcClient Query failed,time is out");
            }

            if (rmc.ThrowIfErrorResponseCode)
            {
                if (receiveData.StateCode != (byte)ResponseCode.OK)
                {
                    throw new RpcException(string.Format("SimpleRpcClient Query failed,error code:{0},message:{1}",
                                                         receiveData.StateCode,
                                                         NetworkSettings.ErrorContentEncoding.GetString(receiveData.ContentBytes ?? FrameFormat.EmptyBytes)));
                }
            }

            return(receiveData);
        }