private void OnLoginEvent(NetMessageData messageHandler)
        {
            Login2Client msg = messageHandler.GetMessage <Login2Client>();

            if (msg.code == 0)
            {
                isLogin = true;
                if (string.IsNullOrEmpty(msg.playerID))
                {
                    msg.playerID = "001";
                }
                Player player = new Player(messageHandler.session);
                player.playerID = msg.playerID;
                player.AddData(msg.appData);

                SimpleNetManager.PlayerManager.AddPlayer(player);
            }
            if (Onlogin != null)
            {
                Onlogin(msg);
            }
            Debug.Log("登录返回:" + msg.code);
        }
        private void OnLoginMsg(NetMessageData messageHandler)
        {
            Debug.Log("接受到登陆消息!");
            Login2Server msg = messageHandler.GetMessage <Login2Server>();

            bool isRightDecryptPW = true;

            //密码解码
            if (!string.IsNullOrEmpty(msg.password))
            {
                try
                {
                    string temp = msg.password;
                    //获得密码md5串长度
                    int length = int.Parse(temp.Substring(0, 4));
                    //Debug.Log("length:" + temp.Substring(0, 4));

                    string md5Ery = temp.Substring(4, length);
                    //Debug.Log("md5Ery:" + md5Ery);
                    string aesKey = temp.Substring(4 + length);
                    //Debug.Log("aesKey:" + aesKey);
                    string pwMD5 = AESUtils.AESDecrypt(md5Ery, aesKey);
                    //Debug.Log("pwMD5:" + pwMD5);
                    msg.password = pwMD5;
                }
                catch (Exception e)
                {
                    Debug.LogError("password Decrypt error:" + msg.password + "\n" + e);
                    isRightDecryptPW = false;
                }
            }

            Login2Client resMsg = new Login2Client();

            resMsg.appData = new AppData();
            resMsg.appData.serverAppName    = Application.productName;
            resMsg.appData.serverAppVersion = Application.version;
            resMsg.appData.bundleIdentifier = Application.identifier;

            Player player = null;

            if (isRightDecryptPW)
            {
                if (SimpleNetManager.PlayerManager.IsLogin(messageHandler.session))
                {
                    //重复登陆
                    resMsg.code = 100;
                }

                else if (playerLoginHandler != null)
                {
                    resMsg.code = playerLoginHandler.LoginLogic(msg, messageHandler.session, out player);
                    // player = new Player(messageHandler.connectionId);
                    //player.playerID = "1000";
                    if (resMsg.code == 0)
                    {
                        if (SimpleNetManager.PlayerManager.IsLogin(player.playerID))
                        {
                            //当前账号已登录
                            resMsg.code = 103;
                        }
                        else
                        {
                            resMsg.playerID = player.playerID;
                        }
                    }
                }
                else
                {
                    //其他错误
                    resMsg.code = 101;
                }
            }
            else
            {
                //密码解析错误
                resMsg.code = 104;
            }

            netManager.Send(messageHandler.session, resMsg);
            SimpleNetManager.PlayerManager.AddPlayer(player);
            if (resMsg.code == 0)
            {
                if (OnPlayerLogin != null)
                {
                    OnPlayerLogin(player);
                }

                if (OnPlayerLoginAfter != null)
                {
                    OnPlayerLoginAfter(player);
                }
            }
        }