コード例 #1
0
 /// <summary>
 /// 绑定各游戏命令的监听
 /// </summary>
 static void BindGameCommandListener()
 {
     QKCommand.RegListener(GameCommand.ShowPayUI.Name, OnShowPayUI);
     QKCommand.RegListener(GameCommand.QuickLogin.Name, OnQuickLogin);
     QKCommand.RegListener(GameCommand.RequestLogin.Name, OnRequestLogin);
     QKCommand.RegListener(GameCommand.RequestRegist.Name, OnRequestRegist);
 }
コード例 #2
0
        /// <summary>
        /// 发送一个命令
        /// </summary>
        public void SendQKCommand(string eventName)
        {
            if (mTransCache.ContainsKey(eventName))// 缓存里有该事件的数据
            {
                // 读取数据,创建命令对象
                QKCommand cmd = new QKCommand(eventName);

                foreach (KeyValuePair <string, string> kv in mTransCache[eventName])
                {
                    cmd.AddParam(kv.Key, kv.Value);
                }

                // 发送命令
                cmd.Send();
                mTransCache.Remove(eventName); // 清除使用过的数据

                //  返回命令的返回信息
                BeginTransToTerminal(cmd.Name);// 开始一个传输任务
                foreach (KeyValuePair <string, object> kv in cmd.Returns)
                {
                    TransToTerminal(cmd.Name, kv.Key, kv.Value as string);
                }
                EndTransToTerminal(cmd.Name); // 结束一个传输任务
            }
        }
コード例 #3
0
        static void OnUserLoginFinished(QKSDKReturn sdkReturn)
        {
            /// ErrorCode:错误码,0代码成功
            /// Msg:描述
            /// User:用户对象
            QKCommand tempCmd = SDKCommand.SDKLoginFinish;

            tempCmd.AddParam("ErrorCode", sdkReturn.ErrorCode);
            tempCmd.AddParam("Msg", sdkReturn.ErrorMsg);

            if (0 == sdkReturn.ErrorCode)
            {
                QKSDKUser tempUser = QKSDKUser.Parse(sdkReturn.Content.TrySecDecode());

                // 缓存非游客用户账号
                if (0 == tempUser.GuestMode)
                {
                    SDKConfig.CacheAccount(mCurrAccount, mCurrPassword);
                }
                else
                {
                    SDKCookie.SetValue("TempAccount", tempUser.Account);
                    SDKCookie.SetValue("TempPassword", tempUser.Account);
                }

                tempCmd.AddParam("User", tempUser);
            }

            tempCmd.Send();
        }
コード例 #4
0
        /// <summary>
        /// 快速登录
        /// </summary>
        static void OnQuickLogin(QKCommand cmd)
        {
            string fromType = AccountFromType.QK;

            // 有临时的账号密码
            if (SDKCookie.ContainKey("TempAccount") && SDKCookie.ContainKey("TempPassword"))
            {
                mCurrAccount  = SDKCookie.GetValue("TempAccount");
                mCurrPassword = SDKCookie.GetValue("TempPassword");

                // 上传的参数
                Dictionary <string, string> upParams = new Dictionary <string, string>();
                upParams["AppKey"]   = SDKConfig.AppKey;
                upParams["Account"]  = mCurrAccount;
                upParams["Password"] = mCurrPassword;
                upParams["FromType"] = fromType;
                upParams["Sign"]     = String.Format("AppKey={0}&Account={1}&FromType={2}&{3}",
                                                     SDKConfig.AppKey, mCurrAccount, fromType, SDKConfig.AppSecret).TryToQKMD5();

                NetTask.AutoFinish(new WWW(LoginUrl, upParams.TryToString().TrySecEncode().TryToBytes()), OnUserLoginFinished);
            }
            else
            {
                // 上传的参数
                Dictionary <string, string> upParams = new Dictionary <string, string>();
                upParams["AppKey"]   = SDKConfig.AppKey;
                upParams["FromType"] = fromType;
                upParams["Sign"]     = String.Format("AppKey={0}&FromType={1}&{2}",
                                                     SDKConfig.AppKey, fromType, SDKConfig.AppSecret).TryToQKMD5();

                NetTask.AutoFinish(new WWW(QuickRegistUrl, upParams.TryToString().TrySecEncode().TryToBytes()), OnUserLoginFinished);
            }
        }
コード例 #5
0
 /// <summary>
 /// 显示登录
 /// </summary>
 void OnShowLoginUI(QKCommand cmd)
 {
     if (cmd.Params.ContainsKey("Type"))
     {
         mUIType = (AccountSystemUIType)(int)cmd.Params["Type"];
     }
     else
     {
         mUIType = AccountSystemUIType.Default;
     }
     CoroutineManage.Single.StartCoroutine(coLoadResource());
 }
コード例 #6
0
        void OnSDKLoginFinished(QKCommand cmd)
        {
            CMaskPanel.Show(false);

            int errorCode = (int)cmd.Params["ErrorCode"];

            if (0 == errorCode)
            {
                CloseUI();
            }
            else
            {
                CTipPanel.ShowTip(CTipType.Yes, (string)cmd.Params["Msg"], null);
            }
        }
コード例 #7
0
        /// <summary>
        /// SDK登录完成
        /// </summary>
        void OnSDKLoginFinished(QKCommand cmd)
        {
            int errorCode = (int)cmd.Params["ErrorCode"];

            if (null != mListener)
            {
                if (0 == errorCode)
                {
                    mListener.OnSDKLoginSuccess((QKSDKUser)cmd.Params["User"]);
                }
                else
                {
                    mListener.OnSDKLoginFailed(errorCode, (string)cmd.Params["Msg"]);
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// 请求注册账号
        /// FromType:来源的账号体系 AccountFromType
        /// Account:账号
        /// Password:密码
        /// </summary>
        static void OnRequestRegist(QKCommand cmd)
        {
            string fromType = (string)cmd.Params["FromType"];

            mCurrAccount  = (string)cmd.Params["Account"];
            mCurrPassword = (string)cmd.Params["Password"];

            // 上传的参数
            Dictionary <string, string> upParams = new Dictionary <string, string>();

            upParams["AppKey"]   = SDKConfig.AppKey;
            upParams["Account"]  = mCurrAccount;
            upParams["Password"] = mCurrPassword;
            upParams["FromType"] = fromType;
            upParams["Sign"]     = String.Format("AppKey={0}&Account={1}&FromType={2}&{3}",
                                                 SDKConfig.AppKey, mCurrAccount, fromType, SDKConfig.AppSecret).TryToQKMD5();

            NetTask.AutoFinish(new WWW(RegistUrl, upParams.TryToString().TrySecEncode().TryToBytes()), OnUserLoginFinished);
        }
コード例 #9
0
        /// <summary>
        /// 当接收到监听的命令时
        /// </summary>
        protected void OnQKCommand(QKCommand cmd)
        {
            BeginTransToTerminal(cmd.Name);// 开始传送数据
            // 传送所有的参数
            foreach (KeyValuePair <string, object> kv in cmd.Params)
            {
                TransToTerminal(cmd.Name, kv.Key, kv.Value as string);
            }
            EndTransToTerminal(cmd.Name);// 传送数据结束

            // 执行命令
            TerminalDoQKCommand(cmd.Name);

            if (mTransCache.ContainsKey(cmd.Name))// 是否有返回
            {
                foreach (KeyValuePair <string, string> kv in mTransCache[cmd.Name])
                {
                    cmd.AddReturn(kv.Key, kv.Value);
                }
            }
        }
コード例 #10
0
 /// <summary>
 /// 解除一个事件监听
 /// </summary>
 public void UnRegQKCommandListener(string eventName)
 {
     // 监听QKCommand
     QKCommand.UnRegListener(eventName, OnQKCommand);
 }
コード例 #11
0
 /// <summary>
 /// 绑定命令监听
 /// </summary>
 void BindCommandListener()
 {
     QKCommand.RegListener(SDKCommand.SDKLoginFinish.Name, OnSDKLoginFinished);
 }
コード例 #12
0
 void Awake()
 {
     mSingle = this;
     QKCommand.RegListener(SDKCommand.ShowLoginUI.Name, OnShowLoginUI);
     QKCommand.RegListener(SDKCommand.SDKLoginFinish.Name, OnSDKLoginFinished);
 }
コード例 #13
0
    public void OnShowLogin()
    {
        QKCommand tempCommand = new QKCommand("ShowLoginUI");

        tempCommand.Send();
    }
コード例 #14
0
 /// <summary>
 /// 显示支付界面
 /// </summary>
 static void OnShowPayUI(QKCommand cmd)
 {
 }