Exemplo n.º 1
0
            /// <summary>
            /// 简单计算测试
            /// </summary>
            public void addAsynchronous(int left, int right, Action <AutoCSer.Net.TcpServer.ReturnValue <AutoCSer.TestCase.TcpServerPerformance.Add> > _onReturn_)
            {
                AutoCSer.Net.Callback <AutoCSer.Net.TcpServer.ReturnValue <TcpOpenStreamServer._p4> > _onOutput_ = _TcpClient_.GetCallback <AutoCSer.TestCase.TcpServerPerformance.Add, TcpOpenStreamServer._p4>(_onReturn_);
                try
                {
                    AutoCSer.Net.TcpOpenStreamServer.ClientSocketSender _socket_ = _TcpClient_.Sender;
                    if (_socket_ != null)
                    {
                        TcpOpenStreamServer._p3 _inputParameter_ = new TcpOpenStreamServer._p3
                        {
                            left = left,

                            right = right,
                        };
                        _socket_.Get <TcpOpenStreamServer._p3, TcpOpenStreamServer._p4>(_ac1, ref _onOutput_, ref _inputParameter_);
                    }
                }
                finally
                {
                    if (_onOutput_ != null)
                    {
                        AutoCSer.Net.TcpServer.ReturnValue <TcpOpenStreamServer._p4> _outputParameter_ = new AutoCSer.Net.TcpServer.ReturnValue <TcpOpenStreamServer._p4> {
                            Type = AutoCSer.Net.TcpServer.ReturnType.ClientException
                        };
                        _onOutput_.Call(ref _outputParameter_);
                    }
                }
            }
Exemplo n.º 2
0
            /// <summary>
            /// 客户端同步计算测试
            /// </summary>
            public async System.Threading.Tasks.Task <AutoCSer.Net.TcpServer.ReturnValue <int> > addAsync(int left, int right)
            {
                AutoCSer.Net.TcpOpenStreamServer.ClientSocketSender _socket_ = _TcpClient_.Sender;
                if (_socket_ != null)
                {
                    AutoCSer.Net.TcpServer.TaskAsyncReturnValue <TcpOpenStreamServer._p2> _wait_ = new AutoCSer.Net.TcpServer.TaskAsyncReturnValue <TcpOpenStreamServer._p2>();
                    TcpOpenStreamServer._p1 _inputParameter_ = new TcpOpenStreamServer._p1
                    {
                        left = left,

                        right = right,
                    };
                    AutoCSer.Net.TcpServer.ReturnType _returnType_;
                    TcpOpenStreamServer._p2           _outputParameter_ = new TcpOpenStreamServer._p2
                    {
                    };
                    if ((_returnType_ = _socket_.GetAsync <TcpOpenStreamServer._p1, TcpOpenStreamServer._p2>(_a0, _wait_, ref _inputParameter_, ref _outputParameter_)) == AutoCSer.Net.TcpServer.ReturnType.Success)
                    {
                        AutoCSer.Net.TcpServer.ReturnValue <TcpOpenStreamServer._p2> _returnOutputParameter_ = await _wait_;
                        return(new AutoCSer.Net.TcpServer.ReturnValue <int> {
                            Type = _returnOutputParameter_.Type, Value = _returnOutputParameter_.Value.Return
                        });
                    }
                    return(new AutoCSer.Net.TcpServer.ReturnValue <int> {
                        Type = _returnType_
                    });
                }
                return(new AutoCSer.Net.TcpServer.ReturnValue <int> {
                    Type = AutoCSer.Net.TcpServer.ReturnType.ClientException
                });
            }
Exemplo n.º 3
0
            /// <summary>
            /// 客户端同步计算测试
            /// </summary>
            public AutoCSer.Net.TcpServer.AwaiterBoxReference <int> addAwaiter(int left, int right)
            {
                AutoCSer.Net.TcpServer.AwaiterBoxReference <int>    _awaiter_ = new AutoCSer.Net.TcpServer.AwaiterBoxReference <int>();
                AutoCSer.Net.TcpOpenStreamServer.ClientSocketSender _socket_  = _TcpClient_.Sender;
                if (_socket_ != null)
                {
                    TcpOpenStreamServer._p1 _inputParameter_ = new TcpOpenStreamServer._p1
                    {
                        left = left,

                        right = right,
                    };
                    AutoCSer.Net.TcpServer.ReturnType _returnType_;
                    AutoCSer.Net.TcpServer.AwaiterReturnValueBoxReference <int> _outputParameter_ = default(AutoCSer.Net.TcpServer.AwaiterReturnValueBoxReference <int>);
                    _returnType_ = _socket_.GetAwaiter <TcpOpenStreamServer._p1, AutoCSer.Net.TcpServer.AwaiterReturnValueBoxReference <int> >(_a0, _awaiter_, ref _inputParameter_, ref _outputParameter_);
                    if (_returnType_ != AutoCSer.Net.TcpServer.ReturnType.Success)
                    {
                        _awaiter_.Call(_returnType_);
                    }
                }
                else
                {
                    _awaiter_.Call(AutoCSer.Net.TcpServer.ReturnType.ClientException);
                }
                return(_awaiter_);
            }
Exemplo n.º 4
0
            /// <summary>
            /// 客户端同步计算测试
            /// </summary>
            public AutoCSer.Net.TcpServer.ReturnValue <int> add(int left, int right)
            {
                AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpOpenStreamServer._p2> _wait_ = AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpOpenStreamServer._p2> .Pop();

                try
                {
                    AutoCSer.Net.TcpOpenStreamServer.ClientSocketSender _socket_ = _TcpClient_.Sender;
                    if (_socket_ != null)
                    {
                        TcpOpenStreamServer._p1 _inputParameter_ = new TcpOpenStreamServer._p1
                        {
                            left = left,

                            right = right,
                        };
                        TcpOpenStreamServer._p2 _outputParameter_ = new TcpOpenStreamServer._p2
                        {
                        };
                        AutoCSer.Net.TcpServer.ReturnType _returnType_ = _socket_.WaitGet <TcpOpenStreamServer._p1, TcpOpenStreamServer._p2>(_c0, ref _wait_, ref _inputParameter_, ref _outputParameter_);
                        return(new AutoCSer.Net.TcpServer.ReturnValue <int> {
                            Type = _returnType_, Value = _outputParameter_.Return
                        });
                    }
                }
                finally
                {
                    if (_wait_ != null)
                    {
                        AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpOpenStreamServer._p2> .PushNotNull(_wait_);
                    }
                }
                return(new AutoCSer.Net.TcpServer.ReturnValue <int> {
                    Type = AutoCSer.Net.TcpServer.ReturnType.ClientException
                });
            }
Exemplo n.º 5
0
        /// <summary>
        /// 时间验证客户端验证
        /// </summary>
        /// <param name="verify">时间验证服务客户端委托</param>
        /// <param name="sender"></param>
        /// <param name="client"></param>
        /// <returns></returns>
        public unsafe static bool Verify(Verifier verify, ClientSocketSender sender, AutoCSer.Net.TcpOpenStreamServer.Client client)
        {
            string verifyString = client.Attribute.VerifyString;

            if (verifyString == null)
            {
                long ticks = 0;
                return(verify(sender, null, 0, null, ref ticks).Value);
            }
            return(Verify(verify, sender, client, null, verifyString));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 时间验证客户端验证
        /// </summary>
        /// <param name="verify">时间验证服务客户端委托</param>
        /// <param name="sender"></param>
        /// <param name="client"></param>
        /// <returns></returns>
        public unsafe static bool Verify(Verifier verify, ClientSocketSender sender, AutoCSer.Net.TcpOpenStreamServer.Client client)
        {
            long            ticks;
            ServerAttribute attribute    = client.Attribute;
            string          verifyString = attribute.VerifyString;

            if (verifyString == null)
            {
                ticks = 0;
                return(verify(sender, 0, null, ref ticks).Value);
            }
            ulong markData = 0;

            if (attribute.IsMarkData)
            {
                markData = attribute.VerifyHashCode;
            }
            ticks = Date.NowTime.SetUtc().Ticks;
            TcpServer.ClientSocketBase socket = sender.ClientSocket;
            do
            {
                ulong randomPrefix = Random.Default.SecureNextULongNotZero();
                while (randomPrefix == markData)
                {
                    randomPrefix = Random.Default.SecureNextULongNotZero();
                }
                socket.ReceiveMarkData = attribute.IsMarkData ? markData ^ randomPrefix : 0UL;
                sender.SendMarkData    = 0;
                long lastTicks = ticks;
                TcpServer.ReturnValue <bool> isVerify = verify(sender, randomPrefix, TcpServer.TimeVerifyServer.Md5(verifyString, randomPrefix, ticks), ref ticks);
                if (isVerify.Value)
                {
                    sender.SendMarkData = socket.ReceiveMarkData;
                    return(true);
                }
                if (isVerify.Type != TcpServer.ReturnType.Success || ticks <= lastTicks)
                {
                    socket.Log.add(AutoCSer.Log.LogType.Error, "TCP客户端验证失败 [" + isVerify.Type.ToString() + "] " + ticks.toString() + " <= " + lastTicks.toString());
                    return(false);
                }
                socket.Log.add(AutoCSer.Log.LogType.Error, "TCP客户端验证时间失败重试 " + ticks.toString() + " - " + lastTicks.toString());
            }while (true);
        }