static void OnLoginResult(string socketstr)
        {
            int code = int.Parse(socketstr.Substring(0, 3));

            byte[]     subidByte    = Crypt.Base64Decode(socketstr.Substring(4));
            string     resultString = Encoding.UTF8.GetString(subidByte);
            ByteBuffer buffer       = new ByteBuffer(UTF8Encoding.UTF8.GetBytes(200 + " " + resultString));

            if (code != 200)
            {
                Debug.LogError("Login Result" + resultString);
            }
            else
            {
                Debug.Log("OnLoginResult :" + resultString);

                Regex    reg     = new Regex(@"([^:]+):([^:]+)@([^@]+)@(.+)");
                string[] splites = Regex.Split(resultString, "[':', '@']");
                //ip, port, uid, subid
                game_ip   = splites[0];
                game_port = splites[1];
                useid     = splites[2];
                subid     = splites[3];
            }

            state = Enum_Login_Auth_State.LOGIN_FINISHED;
            logincb(code);
        }
        static void GetChallenge(string socketline)
        {
            state = Enum_Login_Auth_State.GET_SECRET;

            byte[] challengeByte = Crypt.Base64Decode(socketline);
            if (challengeByte.Length == 8)
            {
                challenge = BitConverter.ToUInt64(challengeByte, 0);
                clientkey = Crypt.GenerateRandomUlong();
                ulong  dhexchangekey = Crypt.dhexchange(clientkey);
                byte[] buf           = BitConverter.GetBytes(dhexchangekey);
                SendMessage(buf);
            }
        }
        static void GetSecret(string socketstr)
        {
            byte[] lineByte = Crypt.Base64Decode(socketstr);
            if (lineByte.Length == 8)
            {
                ulong line = BitConverter.ToUInt64(lineByte, 0);
                secret = Crypt.dhsecret(line, clientkey);
                ulong  hmac = Crypt.hmac64(challenge, secret);
                byte[] buf  = BitConverter.GetBytes(hmac);

                SendMessage(buf);
                state = Enum_Login_Auth_State.SEND_LOGIN;
            }
        }
        static void OnConnect(IAsyncResult asr)
        {
            try
            {
                client.EndConnect(asr);
            }
            catch (Exception e)
            {
                Debug.LogError(string.Format("连接服务器异步结果异常:{0} ", e.Message.ToString()));
                return;
            }

            state = Enum_Login_Auth_State.GET_CHALLENGE;
            client.GetStream().BeginRead(byte_buffer, 0, MAX_READ, new AsyncCallback(OnReadLine), null);
        }
        public static void DoLoginAction(AuthPackage package)
        {
            if (state != Enum_Login_Auth_State.SEND_LOGIN)
            {
                Debug.LogError("不是第一次登录,也不是重新登录的情况下,执行DoLoginAction函数,loginState:" + state);
                return;
            }

            string token = EncodeToken(package);

            Crypt.SetDesKey(BitConverter.GetBytes(secret));
            byte[] etoken = Crypt.DesEncrypt(Encoding.UTF8.GetBytes(token));

            state = Enum_Login_Auth_State.LOGIN_RESULT;
            SendMessage(etoken);
        }