Esempio n. 1
0
        public static string GetForceInfo(HttpClient2 client)
        {
            string outputstr            = client.DownloadBytearr2(GlobalVal.ServerURL + "/root/gateway.action?command=player@getForceInfo", string.Empty, false);
            webAction_createrole action = (webAction_createrole)JsonManager.JsonToObject(outputstr, typeof(webAction_createrole));

            Reward jiangli = action.action.data.reward;

            /*魏:1 蜀:2 吴:3*/
            outputstr = client.Post_retbyte2(GlobalVal.ServerURL + "/root/gateway.action?command=player@setPlayerForce",
                                             string.Empty, "forceId=" + jiangli.forceId);

            Console.WriteLine(outputstr);

            return(outputstr);
        }
Esempio n. 2
0
        public ExcuteState getPlayerList()
        {
            ExcuteState state = new ExcuteState();

            try
            {
                string jsontext = null;
                //byte[] arrOutput = m_client.DownloadBytearr(GlobalVal.CmdURL + "player@getPlayerList", string.Empty, false);
                //byte[] arrDescrypt = ZlibCompress.DecompressBytes(arrOutput);
                while (true)
                {
                    string outputstr = m_client.DownloadBytearr2(GlobalVal.CmdURL + "player@getPlayerList", string.Empty, false);

                    jsontext = Regex.Match(outputstr, "\\[(?<value>.*?)\\]").Groups["value"].Value;

                    if (string.IsNullOrEmpty(jsontext))
                    {// 创角
                        RoleCreate.GetForceInfo(m_client);
                    }
                    else
                    {
                        break;
                    }
                }

                // 目前只有一个角色
                webRole webrole = (webRole)JsonManager.JsonToObject(jsontext, typeof(webRole));
                if (webrole != null)
                {
                    Rolelist.Add(webrole);
                }
                else
                {
                    state.Description = "getPlayerList() 转化json为对象失败, json=" + jsontext;
                    return(state);
                }

                state.State = IdentityCode.Success;
            }
            catch (Exception ex)
            {
                state.Description = "发生异常=" + ex.Message + ";\r\n" + ex.StackTrace;
                return(state);
            }
            return(state);
        }
Esempio n. 3
0
        public ExcuteState getPlayerInfo(webRole role)
        {
            ExcuteState state = new ExcuteState();

            try
            {
                string URL      = GlobalVal.ServerURL + "/root/gateway.action";
                string postdata = "command=player%40getPlayerInfo&version=11%2E01%2E17%2E1&token=1&info=3391&playerId=" + role.playerId;

                string outputstr = m_client.Post_retbyte2(URL, string.Empty, postdata);
                Debug.WriteLine(outputstr);

                string        jsontest   = Regex.Match(outputstr, "player\":(?<value>.*?)\\},").Groups["value"].Value + "}";
                webDetailRole detailinfo = (webDetailRole)JsonManager.JsonToObject(jsontest, typeof(webDetailRole));
                m_roledetail = detailinfo;

                jsontest = Tool.PickupDataStr(outputstr);;
                webCurTask taskInfo = (webCurTask)JsonManager.JsonToObject(jsontest, typeof(webCurTask));
                if (taskInfo.curTask.tasks != null && taskInfo.curTask.tasks.Count() > 0)
                {
                    m_curTask = taskInfo.curTask.tasks[0];
                    // 把信息写入配置文件
                    TaskObj task = TaskObj.getCurTask(m_curTask);
                    // 把任务写入txt
                    // 再获取一次角色列表
                    if (!string.IsNullOrEmpty(TasktxtPath) && File.Exists(TasktxtPath) && task != null)
                    {
                        List <TaskObj> tasklst = null;
                        TaskObj.getTasklistFromTxt(TasktxtPath, ref tasklst);
                        // 搜索列表
                        TaskObj tobj = tasklst.Find(delegate(TaskObj user){ return(user.TaskName == task.TaskName); });
                        if (tobj == null)
                        {//写入文档
                            TaskObj.WriteData2File(TasktxtPath, task.Obj2String());
                        }
                    }
                }
                state.State = IdentityCode.Success;
            }
            catch (Exception ex)
            {
                state.Description = "发生异常=" + ex.Message + ";\r\n" + ex.StackTrace;
                return(state);
            }
            return(state);
        }
Esempio n. 4
0
        public Task RefreshCurTask(bool bDelete = true)
        {
            KeyValuePair <string, string>         pair;
            List <KeyValuePair <string, string> > pairLst = m_rcvpackagelst.FindAll(x => x.Key == "push@task");

            if (pairLst == null || pairLst.Count == 0)
            {
                return(null);
            }
            if (pairLst.Count > 1)
            {
                for (int i = 0; i < pairLst.Count; i++)
                {
                    lock (m_lock)
                    {
                        m_rcvpackagelst.Remove(pairLst[i]);
                    }
                }
                pair = pairLst[pairLst.Count - 1];
            }
            else
            {
                pair = pairLst[0];
            }

            if (default(KeyValuePair <string, string>).Equals(pair))
            {
                return(null);
            }
            string jsonstr = Tool.PickupDataStr(pair.Value);

            if (bDelete)
            {
                lock (m_lock)
                {
                    m_rcvpackagelst.Remove(pair);
                }
            }

            if (string.IsNullOrEmpty(jsonstr))
            {
                Debug.WriteLine("提取json字符串失败,jsonstr=" + jsonstr);
                return(null);
            }
            else
            {
                webCurTask t = null;
                try
                {
                    if (jsonstr.Contains("refreshTask"))
                    {
                        jsonstr = jsonstr.Replace("refreshTask", "tasks");
                    }
                    t = (webCurTask)JsonManager.JsonToObject(jsonstr, typeof(webCurTask));
                }
                catch (Exception ex1)
                {
                    Debug.WriteLine("json转对象失败,str=" + jsonstr);
                }
                if (t == null)
                {
                    Debug.WriteLine("json转对象失败,jsonstr=" + jsonstr);
                }

                if (t.curTask != null && t.curTask.tasks != null && t.curTask.tasks.Count() > 0)
                {
                    return(t.curTask.tasks[0]);
                }
                else
                {
                    Debug.WriteLine("获取当前任务失败,jsonstr=" + jsonstr);
                    return(null);
                }
            }
        }
Esempio n. 5
0
File: Login.cs Progetto: ko9ma7/Gcld
        /// <summary>
        /// 登陆游戏
        /// </summary>
        /// <returns></returns>
        public ExcuteState LoginGame()
        {
            ExcuteState exestate = new ExcuteState();

            exestate.State = IdentityCode.Success;
            return(exestate);

            try
            {
                #region 网页登陆操作
                string URL    = GlobalVal.CenterURL + "/ssoLogin.action?jsoncallback=jsonp1503016397724&funName=getRSAkey";
                string retstr = m_client.DownloadString(URL, string.Empty);
                retstr = retstr.Replace("\r", "").Replace("\n", "");
                string     jsontext = Regex.Match(retstr, "\\((?<value>.*?)\\)").Groups["value"].Value;
                CipherCode cipher   = (CipherCode)JsonManager.JsonToObject(jsontext, typeof(CipherCode));
                if (cipher == null)
                {
                    exestate.Description = "json转化为对象失败,json=" + jsontext;
                    return(exestate);
                }

                ScriptEngine engine     = new ScriptEngine();
                string       scriptpath = AppDomain.CurrentDomain.BaseDirectory + "\\RSA_min.js";
                bool         bSuccess   = engine.LoadScriptFromFile(scriptpath);
                if (!bSuccess)
                {
                    exestate.Description = ("加载脚本失败!脚本路径=" + scriptpath);
                    return(exestate);
                }
                //object retobj = engine.Eval(ScriptLanguage.JavaScript,
                //    "RSAKeyPair(\"233AB\", \"\", \"1234566666\")", engine.Functionbody);

                List <object> lst = new List <object>();
                lst.Add(cipher.public_exponent);
                lst.Add(cipher.public_modulus);
                lst.Add(cipher.tp);
                lst.Add(m_passwd);

                object token     = engine.EvalValue("getToken", lst, engine.Functionbody);
                string stoken    = (string)token;
                long   timeticks = ConvertDateTimeToInt();
                URL = GlobalVal.CenterURL +
                      string.Format("/ssoLogin.action?jsoncallback=jsonp{2}&funName=indexLogin&username={0}&token={1}&remember=true",
                                    m_uname, stoken, timeticks);
                retstr = m_client.DownloadString(URL, string.Empty);

                jsontext = Regex.Match(retstr, "\\((?<value>.*?)\\)").Groups["value"].Value;
                webLoginInfo info = (webLoginInfo)JsonManager.JsonToObject(jsontext, typeof(webLoginInfo));
                if (info == null)
                {
                    exestate.Description = "json转化为对象失败2,json=" + jsontext;
                    return(exestate);
                }
                if (!info.success)
                {
                    return(exestate);
                }

                // 获取个人信息
                URL = GlobalVal.LgnURL + "/html/server/ssoLogin.xhtml";
                string postdata = string.Format("ts={0}&key={1}&userJson=%7B%22encryptInfo%22%3A%22{2}%22%7D&isgameLogin=true",
                                                info.ts, info.key, info.current_user.encryptInfo);

                retstr = m_client.Post(URL, string.Empty, postdata);

                webPersonalInfo gameinfo = (webPersonalInfo)JsonManager.JsonToObject(retstr, typeof(webPersonalInfo));
                m_psInfo = gameinfo;
                jsontext = Regex.Match(retstr, "\\[(?<value>.*?)\\]").Groups["value"].Value;
                List <webGameInfo> ginfo = (List <webGameInfo>)JsonManager.JsonToObject("[" + jsontext + "]", typeof(List <webGameInfo>));
                m_psInfo.phistory = ginfo[0];
                m_strServerName   = ginfo[0].serverName;

                // 快速登录
                URL = GlobalVal.LgnURL + "/quick.xhtml?gid=gcld";
                m_client.ResponseHeaderData = "Location";
                m_client.DownloadString(URL, string.Empty);
                string jumpURL = m_client.ResponseHeaderData;
                if (string.IsNullOrEmpty(jumpURL))
                {
                    exestate.Description = "获取登录服务器失败";
                    return(exestate);
                }

                retstr = m_client.DownloadString(jumpURL, string.Empty);
                if (string.IsNullOrEmpty(retstr))
                {
                    exestate.Description = "获取登录服务器失败2,URL=" + jumpURL;
                    return(exestate);
                }

                jumpURL = Regex.Match(retstr, "frame src=\"(?<value>.*?)\" name=\"gameFrame").Groups["value"].Value;
                if (string.IsNullOrEmpty(jumpURL))
                {
                    exestate.Description = "获取登录服务器失败3,Page=" + retstr;
                    return(exestate);
                }

                retstr = m_client.DownloadString(jumpURL, string.Empty);
                if (string.IsNullOrEmpty(retstr))
                {
                    exestate.Description = "获取登录服务器失败4,URL=" + jumpURL;
                    return(exestate);
                }
                jumpURL             = Regex.Match(retstr, "window.location.href = \"(?<value>.*?)\"").Groups["value"].Value;
                GlobalVal.ServerURL = jumpURL.Substring(0, jumpURL.IndexOf("/root"));
                GlobalVal.CmdURL    = GlobalVal.ServerURL + "/root/gateway.action?command=";
                if (string.IsNullOrEmpty(jumpURL))
                {
                    exestate.Description = "获取登录服务器失败5,Page=" + retstr;
                    return(exestate);
                }

                retstr = m_client.DownloadString(jumpURL, string.Empty);
                if (retstr == "{\"state\":1,\"data\":1}")
                {
                    exestate.State = IdentityCode.Success;
                }
                else
                {
                    exestate.Description = "获取登录服务器失败6,retstr=" + retstr;
                }
                //{
                //    exestate.State = IdentityCode.Success;
                //    m_lgnInfo = info;
                //}
                // = engine.Run("encryptedString", oblist, engine.Functionbody);
                #endregion
            }
            catch (Exception ex)
            {
                exestate.Description = ex.Message + "\r\n" + ex.StackTrace;
                Debug.WriteLine(exestate.Description);
            }

            return(exestate);
        }