/// <summary>
            /// 客户端同步计算测试
            /// </summary>
            public AutoCSer.Net.TcpServer.ReturnValue <int> add(int left, int right)
            {
                AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpOpenServer._p2> _wait_ = AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpOpenServer._p2> .Pop();

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

                            right = right,
                        };
                        TcpOpenServer._p2 _outputParameter_ = new TcpOpenServer._p2
                        {
                        };
                        AutoCSer.Net.TcpServer.ReturnType _returnType_ = _socket_.WaitGet <TcpOpenServer._p1, TcpOpenServer._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 <TcpOpenServer._p2> .PushNotNull(_wait_);
                    }
                }
                return(new AutoCSer.Net.TcpServer.ReturnValue <int> {
                    Type = AutoCSer.Net.TcpServer.ReturnType.ClientException
                });
            }
Exemplo n.º 2
0
            AutoCSer.Net.TcpServer.ReturnValue <bool> appendLog(AutoCSer.Net.TcpRegister.ServerLog server)
            {
                AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpInternalServer._p5> _wait_ = AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpInternalServer._p5> .Pop();

                try
                {
                    AutoCSer.Net.TcpInternalServer.ClientSocketSender _socket_ = _TcpClient_.Sender;
                    if (_socket_ != null)
                    {
                        TcpInternalServer._p4 _inputParameter_ = new TcpInternalServer._p4
                        {
                            p0 = server,
                        };
                        TcpInternalServer._p5 _outputParameter_ = new TcpInternalServer._p5
                        {
                        };
                        AutoCSer.Net.TcpServer.ReturnType _returnType_ = _socket_.WaitGet <TcpInternalServer._p4, TcpInternalServer._p5>(_c3, ref _wait_, ref _inputParameter_, ref _outputParameter_);
                        return(new AutoCSer.Net.TcpServer.ReturnValue <bool> {
                            Type = _returnType_, Value = _outputParameter_.Return
                        });
                    }
                }
                finally
                {
                    if (_wait_ != null)
                    {
                        AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpInternalServer._p5> .PushNotNull(_wait_);
                    }
                }
                return(new AutoCSer.Net.TcpServer.ReturnValue <bool> {
                    Type = AutoCSer.Net.TcpServer.ReturnType.ClientException
                });
            }
Exemplo n.º 3
0
        private static void pushLink(AutoWaitReturnValue value, AutoWaitReturnValue end, int count)
        {
            System.Threading.Interlocked.Add(ref poolCount, count);
            AutoWaitReturnValue headValue;

            do
            {
                if ((headValue = poolHead) == null)
                {
                    end.next = null;
                    if (System.Threading.Interlocked.CompareExchange(ref poolHead, value, null) == null)
                    {
                        return;
                    }
                }
                else
                {
                    end.next = headValue;
                    if (System.Threading.Interlocked.CompareExchange(ref poolHead, value, headValue) == headValue)
                    {
                        return;
                    }
                }
                AutoCSer.Threading.ThreadYield.Yield(AutoCSer.Threading.ThreadYield.Type.YieldLinkPush);
            }while (true);
        }
Exemplo n.º 4
0
            AutoCSer.Net.TcpServer.ReturnValue <ulong> append(AutoCSer.DiskBlock.AppendBuffer buffer)
            {
                AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpInternalServer._p2> _wait_ = AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpInternalServer._p2> .Pop();

                try
                {
                    AutoCSer.Net.TcpInternalServer.ClientSocketSender _socket_ = _TcpClient_.Sender;
                    if (_socket_ != null)
                    {
                        TcpInternalServer._p1 _inputParameter_ = new TcpInternalServer._p1
                        {
                            p0 = buffer,
                        };
                        TcpInternalServer._p2 _outputParameter_ = new TcpInternalServer._p2
                        {
                        };
                        AutoCSer.Net.TcpServer.ReturnType _returnType_ = _socket_.WaitGet <TcpInternalServer._p1, TcpInternalServer._p2>(_c0, ref _wait_, ref _inputParameter_, ref _outputParameter_);
                        return(new AutoCSer.Net.TcpServer.ReturnValue <ulong> {
                            Type = _returnType_, Value = _outputParameter_.Return
                        });
                    }
                }
                finally
                {
                    if (_wait_ != null)
                    {
                        AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpInternalServer._p2> .PushNotNull(_wait_);
                    }
                }
                return(new AutoCSer.Net.TcpServer.ReturnValue <ulong> {
                    Type = AutoCSer.Net.TcpServer.ReturnType.ClientException
                });
            }
Exemplo n.º 5
0
        //[AutoCSer.IOS.Preserve(Conditional = true)]
        public static void PushNotNull(AutoWaitReturnValue value)
        {
            if (poolCount >= poolMaxCount)
            {
                return;
            }
            System.Threading.Interlocked.Increment(ref poolCount);
            AutoWaitReturnValue headValue;

            do
            {
                if ((headValue = poolHead) == null)
                {
                    value.next = null;
                    if (System.Threading.Interlocked.CompareExchange(ref poolHead, value, null) == null)
                    {
                        return;
                    }
                }
                else
                {
                    value.next = headValue;
                    if (System.Threading.Interlocked.CompareExchange(ref poolHead, value, headValue) == headValue)
                    {
                        return;
                    }
                }
                AutoCSer.Threading.ThreadYield.Yield(AutoCSer.Threading.ThreadYield.Type.YieldLinkPush);
            }while (true);
        }
 /// <summary>
 /// 发送消息
 /// </summary>
 /// <param name="content">消息内容</param>
 public AutoCSer.Net.TcpServer.ReturnValue send(string content)
 {
     AutoCSer.Net.TcpServer.AutoWaitReturnValue _wait_ = AutoCSer.Net.TcpServer.AutoWaitReturnValue.Pop();
     try
     {
         AutoCSer.Net.TcpOpenServer.ClientSocketSender _socket_ = _TcpClient_.Sender;
         if (_socket_ != null)
         {
             TcpOpenServer._p3 _inputParameter_ = new TcpOpenServer._p3
             {
                 content = content,
             };
             return(new AutoCSer.Net.TcpServer.ReturnValue {
                 Type = _socket_.WaitCall(_c2, ref _wait_, ref _inputParameter_)
             });
         }
     }
     finally
     {
         if (_wait_ != null)
         {
             AutoCSer.Net.TcpServer.AutoWaitReturnValue.PushNotNull(_wait_);
         }
     }
     return(new AutoCSer.Net.TcpServer.ReturnValue {
         Type = AutoCSer.Net.TcpServer.ReturnType.ClientException
     });
 }
            /// <summary>
            /// 用户登录
            /// </summary>
            /// <param name="userName">用户名称</param>
            /// <returns>是否成功</returns>
            public AutoCSer.Net.TcpServer.ReturnValue <bool> login(AutoCSer.Net.TcpOpenServer.ClientSocketSender _sender_, string userName)
            {
                AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpOpenServer._p2> _wait_ = AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpOpenServer._p2> .Pop();

                try
                {
                    AutoCSer.Net.TcpOpenServer.ClientSocketSender _socket_ = _sender_;
                    if (_socket_ != null)
                    {
                        TcpOpenServer._p1 _inputParameter_ = new TcpOpenServer._p1
                        {
                            userName = userName,
                        };
                        TcpOpenServer._p2 _outputParameter_ = new TcpOpenServer._p2
                        {
                        };
                        AutoCSer.Net.TcpServer.ReturnType _returnType_ = _socket_.WaitGet <TcpOpenServer._p1, TcpOpenServer._p2>(_c0, ref _wait_, ref _inputParameter_, ref _outputParameter_);
                        return(new AutoCSer.Net.TcpServer.ReturnValue <bool> {
                            Type = _returnType_, Value = _outputParameter_.Return
                        });
                    }
                }
                finally
                {
                    if (_wait_ != null)
                    {
                        AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpOpenServer._p2> .PushNotNull(_wait_);
                    }
                }
                return(new AutoCSer.Net.TcpServer.ReturnValue <bool> {
                    Type = AutoCSer.Net.TcpServer.ReturnType.ClientException
                });
            }
 /// <summary>
 /// GC 垃圾回收
 /// </summary>
 public AutoCSer.Net.TcpServer.ReturnValue gcCollect()
 {
     AutoCSer.Net.TcpServer.AutoWaitReturnValue    _wait_   = AutoCSer.Net.TcpServer.AutoWaitReturnValue.Pop();
     AutoCSer.Net.TcpOpenServer.ClientSocketSender _socket_ = null;
     try
     {
         _socket_ = _TcpClient_.Sender;
         if (_socket_ != null)
         {
             return(new AutoCSer.Net.TcpServer.ReturnValue {
                 Type = _socket_.WaitCall(_c7, ref _wait_)
             });
         }
     }
     finally
     {
         if (_wait_ != null)
         {
             AutoCSer.Net.TcpServer.AutoWaitReturnValue.PushNotNull(_wait_);
         }
     }
     return(new AutoCSer.Net.TcpServer.ReturnValue {
         Type = _socket_ == null ? AutoCSer.Net.TcpServer.ReturnType.ClientSocketNull : AutoCSer.Net.TcpServer.ReturnType.ClientException
     });
 }
Exemplo n.º 9
0
            AutoCSer.Net.TcpServer.ReturnValue <bool> verify(AutoCSer.Net.TcpInternalServer.ClientSocketSender _sender_, string userID, ulong randomPrefix, byte[] md5Data, ref long ticks)
            {
                AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpInternalServer._p4> _wait_ = AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpInternalServer._p4> .Pop();

                AutoCSer.Net.TcpInternalServer.ClientSocketSender _socket_ = null;
                try
                {
                    _socket_ = _sender_;
                    if (_socket_ != null)
                    {
                        TcpInternalServer._p3 _inputParameter_ = new TcpInternalServer._p3
                        {
                            p2 = userID,

                            p3 = randomPrefix,

                            p0 = md5Data,

                            p1 = ticks,
                        };
                        TcpInternalServer._p4 _outputParameter_ = new TcpInternalServer._p4
                        {
                            p0 = ticks,
                        };
                        AutoCSer.Net.TcpServer.ReturnType _returnType_ = _socket_.WaitGet <TcpInternalServer._p3, TcpInternalServer._p4>(_c1, ref _wait_, ref _inputParameter_, ref _outputParameter_);

                        ticks = _outputParameter_.p0;
                        return(new AutoCSer.Net.TcpServer.ReturnValue <bool> {
                            Type = _returnType_, Value = _outputParameter_.Return
                        });
                    }
                }
                finally
                {
                    if (_wait_ != null)
                    {
                        AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpInternalServer._p4> .PushNotNull(_wait_);
                    }
                }
                return(new AutoCSer.Net.TcpServer.ReturnValue <bool> {
                    Type = _socket_ == null ? AutoCSer.Net.TcpServer.ReturnType.ClientSocketNull : AutoCSer.Net.TcpServer.ReturnType.ClientException
                });
            }
Exemplo n.º 10
0
        /// <summary>
        /// 清除缓存数据
        /// </summary>
        /// <param name="count">保留缓存数据数量</param>
        private static void clearCache(int count)
        {
            AutoWaitReturnValue headValue = System.Threading.Interlocked.Exchange(ref poolHead, null);

            poolCount = 0;
            if (headValue != null && count != 0)
            {
                int pushCount           = count;
                AutoWaitReturnValue end = headValue;
                while (--count != 0)
                {
                    if (end.next == null)
                    {
                        pushLink(headValue, end, pushCount - count);
                        return;
                    }
                    end = end.next;
                }
                end.next = null;
                pushLink(headValue, end, pushCount);
            }
        }
Exemplo n.º 11
0
            AutoCSer.Net.TcpServer.ReturnValue <AutoCSer.DiskBlock.ClientBuffer> read(AutoCSer.DiskBlock.ClientBuffer buffer, ulong index)
            {
                AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpInternalServer._p6> _wait_ = AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpInternalServer._p6> .Pop();

                AutoCSer.Net.TcpInternalServer.ClientSocketSender _socket_ = null;
                try
                {
                    _socket_ = _TcpClient_.Sender;
                    if (_socket_ != null)
                    {
                        TcpInternalServer._p5 _inputParameter_ = new TcpInternalServer._p5
                        {
                            p0 = buffer,

                            p1 = index,
                        };
                        TcpInternalServer._p6 _outputParameter_ = new TcpInternalServer._p6
                        {
                            Ret = buffer
                        };
                        AutoCSer.Net.TcpServer.ReturnType _returnType_ = _socket_.WaitGet <TcpInternalServer._p5, TcpInternalServer._p6>(_c2, ref _wait_, ref _inputParameter_, ref _outputParameter_);
                        return(new AutoCSer.Net.TcpServer.ReturnValue <AutoCSer.DiskBlock.ClientBuffer> {
                            Type = _returnType_, Value = _outputParameter_.Return
                        });
                    }
                }
                finally
                {
                    if (_wait_ != null)
                    {
                        AutoCSer.Net.TcpServer.AutoWaitReturnValue <TcpInternalServer._p6> .PushNotNull(_wait_);
                    }
                }
                return(new AutoCSer.Net.TcpServer.ReturnValue <AutoCSer.DiskBlock.ClientBuffer> {
                    Type = _socket_ == null ? AutoCSer.Net.TcpServer.ReturnType.ClientSocketNull : AutoCSer.Net.TcpServer.ReturnType.ClientException
                });
            }