public override void read(ErlKVMessage message) { ErlArray str = message.getValue("msg") as ErlArray; if (str != null) { ArenaGuessUser[] users = new ArenaGuessUser[2]; for (int i = 0; i < 2; i++) { ErlArray arr = str.Value[i] as ErlArray; if (arr != null) { int pos = 0; ArenaGuessUser user = new ArenaGuessUser(); user.uid = arr.Value[pos++].getValueString(); user.name = arr.Value[pos++].getValueString(); user.headIcon = StringKit.toInt(arr.Value[pos++].getValueString()); user.level = StringKit.toInt(arr.Value[pos++].getValueString()); user.guild = arr.Value[pos++].getValueString(); user.select = bool.Parse(arr.Value[pos++].getValueString()); users[i] = user; } } if (callback != null) { callback(users); } } }
public override void read(ErlKVMessage message) { ErlArray arr = message.getValue("msg") as ErlArray; if (arr != null) { ErlArray arr2 = arr.Value[0] as ErlArray; // 增加之后的运势 int num = StringKit.toInt(arr2.Value[0].getValueString()); // 非分享增加的运势 int num1 = StringKit.toInt(arr2.Value[1].getValueString()); // 分享增加的运势 int shareAward = StringKit.toInt(arr2.Value[2].getValueString()); // 基础奖励(不管任何情况都奖励) int awardSid = StringKit.toInt(arr.Value[1].getValueString()); callback(num1, awardSid, shareAward); } else if ((message.getValue("msg") as ErlType).getValueString() == "limit") { UiManager.Instance.getWindow <DivineWindow>().finishWindow(); } else { MessageWindow.ShowAlert((message.getValue("msg") as ErlType).getValueString()); if (callback != null) { callback = null; } } }
public override void read(ErlKVMessage message) { ErlType msgType = message.getValue("msg") as ErlType; if (msgType != null && msgType is ErlArray) { ErlArray buyArray = msgType as ErlArray; if (buyArray.Value[0].getValueString() == "ok") { StorageManagerment.Instance.parseAddStorageProps(buyArray.Value[1] as ErlArray); if (callback != null) { callback(); } } else { UiManager.Instance.openDialogWindow <MessageLineWindow>((win) => { win.Initialize(LanguageConfigManager.Instance.getLanguage("OneOnOneBoss_425")); }); } } else { UiManager.Instance.openDialogWindow <MessageLineWindow>((win) => { win.Initialize(LanguageConfigManager.Instance.getLanguage("OneOnOneBoss_425")); }); } callback = null; }
//构建攻击行为 private void createAbiltyAttack(BattleSkillMsg msg, ErlArray array) { //攻击者 id string str1 = array.Value [0].getValueString(); msg.userID = StringKit.toInt(str1); // 技能sid编号 string str2 = array.Value [1].getValueString(); msg.skillSID = StringKit.toInt(str2); // 技能编号 string str3 = array.Value [2].getValueString(); msg.skillID = StringKit.toInt(str3); //erlArray 被攻击者 编号可以是多个 ErlArray arr4 = array.Value [3] as ErlArray; int[] strarr = new int[arr4.Value.Length]; //生成被攻击者编号数组 for (int m = 0; m < strarr.Length; m++) { strarr [m] = StringKit.toInt(arr4.Value [m].getValueString()); } msg.targets = strarr; }
/// <summary> /// 钻石裂魂 /// </summary> private void HuntStarSoulByRmb(int index, ErlArray arr) { StarSoulManager manager = StarSoulManager.Instance; StorageManagerment smanager = StorageManagerment.Instance; ArrayList starSouls = new ArrayList(); int debrisNumber = StringKit.toInt(arr.Value [index++].getValueString()); if (debrisNumber > 0) { manager.addDebrisNumber(debrisNumber); } ErlArray starSoulArr = arr.Value [index++] as ErlArray; if (starSoulArr != null && starSoulArr.Value.Length > 0) { StarSoul starSoul; for (int i = 0; i < starSoulArr.Value.Length; i++) { starSoul = manager.createStarSoul(starSoulArr.Value[i] as ErlArray); smanager.addHuntStarSoulStorage(starSoul, true); starSoul.isNew = false; starSouls.Add(starSoul); } StorageManagerment.Instance.huntStarSoulStorageVersion++; } if (callback != null) { callback(starSouls, debrisNumber, 0); callback = null; } }
private void LoadFriendChatFromLocal() { try { string path = PathKit.RESROOT + string.Format(CHAT_CACHE_DIR, UserManager.Instance.self.uid); if (!File.Exists(path)) { return; } FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read); byte[] bytes = new byte[fs.Length]; fs.Read(bytes, 0, (int)fs.Length); fs.Close(); mCacheFriendChats = new List <string> (); mCacheFriendErlArr = new List <ErlArray> (); string[] arr = Encoding.UTF8.GetString(bytes).Split('\n'); for (int i = 0; i < arr.Length; i++) { string[] item = arr[i].Split('\t'); mCacheFriendChats.Add(item[0]); mCacheFriendErlArr.Add(ErlArray.strToErlArr(item[1])); } } catch (System.Exception e) { Debug.Log(e.Message); } }
/// <summary> /// 强化星魂通讯读取处理 /// </summary> /// <param name="message">Message.</param> private void doStrengStarSoul(ErlKVMessage message) { ErlType erlType = message.getValue("value") as ErlType; if (erlType is ErlArray) { ErlArray arr = erlType as ErlArray; int index = 0; string uid = arr.Value [index++].getValueString(); long exp = StringKit.toLong(arr.Value [index++].getValueString()); StorageManagerment smanager = StorageManagerment.Instance; StarSoulManager manager = StarSoulManager.Instance; StarSoul starSoul = smanager.getStarSoul(uid); if (starSoul != null) { manager.delStarSoulExp(exp); starSoul.updateExp(starSoul.getEXP() + exp); starSoul.isNew = false; } StorageManagerment.Instance.starSoulStorageVersion++; if (callback != null) { callback(); callback = null; } } else { UiManager.Instance.openDialogWindow <MessageWindow> ((win) => { win.initWindow(1, LanguageConfigManager.Instance.getLanguage("s0093"), null, erlType.getValueString(), null); }); } }
private void SaveFriendChatToLocal() { string cacheStr = ""; for (int i = 0; i < mCacheFriendChats.Count && i < mCacheFriendErlArr.Count; i++) { if (mCacheFriendChats[i].Length <= 0) { continue; } cacheStr += mCacheFriendChats[i] + "\t" + ErlArray.erlArrToStr(mCacheFriendErlArr[i]); if (i != mCacheFriendChats.Count - 1) { cacheStr += "\n"; } } string path = PathKit.RESROOT + string.Format(CHAT_CACHE_DIR, UserManager.Instance.self.uid); FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); sw.Flush(); sw.BaseStream.Seek(0, SeekOrigin.Begin); sw.Write(cacheStr); sw.Close(); }
/// <summary> /// 创建星魂信息对象 /// </summary> /// <param name="array">元组数据结构</param> public StarSoulInfo createStarSoulInfo(ErlArray array) { StarSoulInfo starSoulInfo = new StarSoulInfo(); starSoulInfo.bytesRead(0, array); return(starSoulInfo); }
/// <summary> /// 提升装备数据处理 /// </summary> private void doRemakeEquip(ErlArray erlArray, int index) { string msgInfo = erlArray.Value [index++].getValueString(); if (msgInfo == "ok") { int noticeSid = StringKit.toInt(erlArray.Value [index++].getValueString()); NoticeActiveManagerment manager = NoticeActiveManagerment.Instance; DoubleRMBInfo info = manager.getActiveInfoBySid(noticeSid) as DoubleRMBInfo; if (info != null) { info.state = true; } else { manager.putActiveInfo(noticeSid, new DoubleRMBInfo(noticeSid, true)); } if (callback != null) { callback(); callback = null; } } else { MessageWindow.ShowAlert(msgInfo); } }
//解析ErlKVMessgae public void parseKVMsg(ErlKVMessage message) { ErlArray exchangeArray = message.getValue("exchange") as ErlArray; ErlArray afficheArray = message.getValue("affiche") as ErlArray; int sid, start, end; ErlArray values; for (int i = 0; i < exchangeArray.Value.Length; i++) { values = exchangeArray.Value [i] as ErlArray; if (values.Value.Length == 3) //未生效,开始结束时间 { sid = StringKit.toInt((values.Value [0] as ErlType).getValueString()); start = StringKit.toInt((values.Value [1] as ErlType).getValueString()); end = StringKit.toInt((values.Value [2] as ErlType).getValueString()); NoticeManagerment.Instance.addExchangeTime(sid, new int[] { start, end }); } } for (int i = 0; i < afficheArray.Value.Length; i++) { values = afficheArray.Value [i] as ErlArray; if (values.Value.Length == 3) //未生效,开始结束时间 { sid = StringKit.toInt((values.Value [0] as ErlType).getValueString()); start = StringKit.toInt((values.Value [1] as ErlType).getValueString()); end = StringKit.toInt((values.Value [2] as ErlType).getValueString()); NoticeManagerment.Instance.addRechargeTime(sid, new int[] { start, end }); } } }
/// <summary> /// 创建星魂对象 /// </summary> /// <param name="array">元组数据结构</param> public StarSoul createStarSoul(ErlArray array) { StarSoul starSoul = new StarSoul(); starSoul.bytesRead(0, array); return(starSoul); }
//解析ErlKVMessgae public bool parseKVMsg(ErlKVMessage message) { ErlType type = message.getValue("msg") as ErlType; if (type is ErlArray) { ErlArray stateArray = type as ErlArray; string state = stateArray.Value[0].getValueString(); if (state == "ok") { TotalLoginManagerment.Instance.HolidayState = true; TotalLoginManagerment.Instance.updateHolidasyAwardData(stateArray.Value[1] as ErlArray); } else if (state == "close") { TotalLoginManagerment.Instance.HolidayState = false; } return(true); } else { MonoBase.print(GetType() + "==" + type.getValueString()); } return(false); }
//替换buffer private void createBufferReplace(BattleSkillMsg msg, ErlArray array) { //被替换buffer者 string str1 = array.Value [0].getValueString(); int[] arrInt1 = new int[1] { StringKit.toInt(str1) }; msg.targets = arrInt1; //旧技能sid string str2 = array.Value [1].getValueString(); msg.oldSkillSID = StringKit.toInt(str2); //旧技能id string str3 = array.Value [2].getValueString(); msg.oldSkillID = StringKit.toInt(str3); //替换后的buffer sid string str4 = array.Value [3].getValueString(); msg.skillSID = StringKit.toInt(str4); //替换后的buffer id string str5 = array.Value [4].getValueString(); msg.skillID = StringKit.toInt(str5); }
//解析ErlKVMessgae public bool parseKVMsg(ErlKVMessage message) { string str = (message.getValue("msg") as ErlType).getValueString(); bool hasPvp = false; if (str == "ok") { hasPvp = true; ErlType type = message.getValue("info") as ErlType; if (type is ErlArray) { ErlArray array = type as ErlArray; //pvp信息过期时间戳 int time = StringKit.toInt(array.Value [0].getValueString()); string rule = array.Value [1].getValueString(); int round = StringKit.toInt(array.Value [2].getValueString()); ErlArray arrays = array.Value [3] as ErlArray; int max = arrays.Value.Length; List <PvpOppInfo> oppList = new List <PvpOppInfo> (); for (int i = 0; i < max; i++) { ErlArray list = arrays.Value [i] as ErlArray; oppList.Add(PvpOppInfo.pares(list)); } PvpInfoManagerment.Instance.createPvpInfo(time, rule, round, oppList.ToArray()); } } else if (str == "no_pvp") { PvpInfoManagerment.Instance.clearDate(); } return(hasPvp); }
public override void read(ErlKVMessage message) { base.read(message); ErlType type = message.getValue("msg") as ErlType; if (type is ErlArray) { ErlArray array = type as ErlArray; RankManagerment.Instance.guildAreaHurtList.Clear(); for (int i = 0; i < array.Value.Length; ++i) { ErlArray temp = array.Value[i] as ErlArray; int index = 0; string uid = temp.Value[index++].getValueString(); string name = temp.Value[index++].getValueString(); int vipLevel = StringKit.toInt(temp.Value[index++].getValueString()); string warNum = temp.Value[index++].getValueString(); string hurtNum = temp.Value[index++].getValueString(); GuildAreaHurtRankItem item = new GuildAreaHurtRankItem(uid, name, warNum, hurtNum); RankManagerment.Instance.guildAreaHurtList.Add(item); } if (callBack != null) { callBack(); } } }
public override void read(ErlKVMessage message) { ErlType type = message.getValue("msg") as ErlType; if (type.getValueString() == "non_mem") { UiManager.Instance.openDialogWindow <MessageWindow>((win) => { win.initWindow(1, LanguageConfigManager.Instance.getLanguage("s0093"), null, LanguageConfigManager.Instance.getLanguage("Guild_90"), GuildManagerment.Instance.closeAllGuildWindow); }); return; } ErlArray array = type as ErlArray; if (array.Value.Length > 0) { for (int i = 0; i < array.Value.Length; i++) { ErlArray temp = array.Value[i] as ErlArray; string sid = temp.Value[0].getValueString(); ErlArray temps = temp.Value[1] as ErlArray; int num = StringKit.toInt(temps.Value[0].getValueString()); int buyTime = StringKit.toInt(temps.Value[1].getValueString()); //GuildGood shop = new GuildGood(sid,num,buyTime); //GuildManagerment.Instance.createGuildShop(shop); } } if (callback != null) { callback(); } }
public override void read(ErlKVMessage message) { ErlArray arr = message.Value[1] as ErlArray; if (arr == null) { return; } for (int i = 0; i < arr.Value.Length; i++) { ErlArray item = arr.Value[i] as ErlArray; int index = StringKit.toInt(item.Value[0].getValueString()); int time = StringKit.toInt(item.Value[1].getValueString()); if (index == 1) { index = 2; } else if (index == 2) { index = 1; } else if (index == 3) { index = 0; } callback(index, time); } }
//构建改变属性 private void createAttrChange(BattleDataErlang battleData, BattleSkillMsg msg, ErlArray array) { //被改变者id string str1 = array.Value [0].getValueString(); int[] arrInt1 = new int[1] { StringKit.toInt(str1) }; msg.targets = arrInt1; //改变的具体属性 数字代替 string str2 = array.Value [1].getValueString(); msg.valueType = StringKit.toInt(str2); //具体数值 string str3 = array.Value [2].getValueString(); msg.damage = StringKit.toInt(str3); if (msg.valueType == 1) { BattleHpInfo info = null; if (battleData.hpMap.ContainsKey(msg.targets [0])) { info = battleData.hpMap [msg.targets [0]]; } else { info = new BattleHpInfo(); battleData.hpMap.Add(msg.targets [0], info); } info.hp += msg.damage; } }
/// <summary> /// 星魂加锁 /// </summary> /// <param name="lockinfo">锁信息串</param> /// <param name="callback">callback</param> /// <summary> /// 回调读取通讯 /// </summary> /// <param name="message">Message.</param> public override void read(ErlKVMessage message) { ErlType type = message.getValue("msg") as ErlType; List <string> goodids = null; if (type is ErlArray) { ErlArray arr = type as ErlArray; if (arr != null && arr.Value.Length > 0) { for (int i = 0; i < arr.Value.Length; i++) { if (goodids == null) { goodids = new List <string>(); } goodids.Add(arr.Value[i].getValueString()); } } if (callback != null) { callback(goodids); callback = null; } } else { UiManager.Instance.openDialogWindow <MessageWindow>((win) => { win.initWindow(1, LanguageConfigManager.Instance.getLanguage("s0093"), null, type.getValueString(), null); }); } }
public override void read(ErlKVMessage message) { ErlArray arr = message.getValue("msg") as ErlArray; int i = 0; new MiniUserFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); new MiniStorageFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); new MiniArmyGetFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); new MiniTotalLoginFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); new MiniMailGetFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); new MiniInitTaskFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); //new MiniPvpGetInfoFPort().parseKVMsg (getKVMsg (arr.Value [i++] as ErlArray)); new MiniExchangeInfoFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); new MiniInitLuckyDrawFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); new MiniFuBenInfoFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); //剧情副本 new MiniFuBenInfoFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); //讨伐副本 new MiniGuideGetInfoFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); new MiniPyxFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); new MiniBeastAddInfoFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); new MiniFriendsFPort().parseKVMsgTypeInit(getKVMsg(arr.Value [i++] as ErlArray)); new MiniGoddessAstrolabeFPort().initInfoByServer(getKVMsg(arr.Value [i++] as ErlArray)); new MiniGetStarInfoFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); new MiniFriendsShareFPort().parseKVMsgTypeInit(getKVMsg(arr.Value [i++] as ErlArray)); new MiniHeroRoadFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); new MiniArenaGetStateFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); new MiniGuildGetInfoFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); new MiniGuildGetApplyListFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); new MiniDivineGetInfoFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); new MiniNoticeGetTimeFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); StringKit.toInt((getKVMsg(arr.Value [i++] as ErlArray).getValue("msg") as ErlType).getValueString()); new MiniNoticetHeroEatInfoFPort().parseKVMsg(getKVMsg(arr.Value [i++] as ErlArray)); //公会建筑等级未获取 callback(); }
public override void read(ErlKVMessage message) { ErlType msgInfo = message.getValue("msg") as ErlType; if (msgInfo is ErlArray) // 买过// { ErlArray infoArr = msgInfo as ErlArray; WeekCardInfo.Instance.endTime = StringKit.toInt(infoArr.Value[0].getValueString()); if (ServerTimeKit.getSecondTime() > WeekCardInfo.Instance.endTime) // 已过期// { WeekCardInfo.Instance.weekCardState = WeekCardState.over; } else { WeekCardInfo.Instance.weekCardState = WeekCardState.open; } WeekCardInfo.Instance.recevieState = StringKit.toInt(infoArr.Value[1].getValueString()); } else // 没有买过// { WeekCardInfo.Instance.weekCardState = WeekCardState.not_open; } if (callBack != null) { callBack(); } }
public void parseMAward(ErlArray date) { string type = (date.Value[0] as ErlType).getValueString(); ErlArray arr = date.Value[1] as ErlArray; Award[] awards = new Award[arr.Value.Length]; ErlArray arr1; for (int i = 0; i < awards.Length; i++) { arr1 = arr.Value[i] as ErlArray; awards[i] = new Award(); awards[i].type = (arr1.Value[0]).getValueString(); parse(arr1.Value[1] as ErlArray, awards[i]); } if (type == AwardManagerment.AWARDS_PVP_DOUBLE)//把连胜奖励分离出来 { AwardManagerment.Instance.addAwards(type, awards); } else { List <Award> lsit = new List <Award>(); if (AwardManagerment.Instance.miaoShaAward != null && AwardManagerment.Instance.miaoShaAward.Length > 0) { lsit.AddRange(AwardManagerment.Instance.miaoShaAward); } lsit.AddRange(awards); AwardManagerment.Instance.miaoShaAward = lsit.ToArray(); } }
/// <summary> /// 普通裂魂 /// </summary> private void huntStarSoul(int index, ErlArray arr) { StarSoulManager manager = StarSoulManager.Instance; StorageManagerment smanager = StorageManagerment.Instance; ArrayList starSouls = new ArrayList(); // 猎魂库sid int huntLibSid = StringKit.toInt(arr.Value [index++].getValueString()); manager.setHuntQuality(huntLibSid); ErlArray starSoulArr = arr.Value [index++] as ErlArray; if (starSoulArr != null && starSoulArr.Value.Length > 0) { StarSoul starSoul; for (int i = 0; i < starSoulArr.Value.Length; i++) { starSoul = manager.createStarSoul(starSoulArr.Value[i] as ErlArray); smanager.addHuntStarSoulStorage(starSoul, true); starSoul.isNew = false; starSouls.Add(starSoul); } StorageManagerment.Instance.huntStarSoulStorageVersion++; } int num = StringKit.toInt(arr.Value[index++].getValueString()); manager.setDebrisNumber(manager.getDebrisNumber() + num); if (callback != null) { callback(starSouls, num, huntLibSid); callback = null; } }
public override void read(ErlKVMessage message) { ErlType str = message.getValue("msg") as ErlType; if (str is ErlArray) { ErlArray arr = str as ErlArray; List <GodsWarMySuportInfo> list = new List <GodsWarMySuportInfo>(); if (arr.Value.Length != 0) { for (int i = 0; i < arr.Value.Length; i++) { ErlArray tmp = arr.Value[i] as ErlArray; GodsWarMySuportInfo user = new GodsWarMySuportInfo(); user.bytesRead(tmp); list.Add(user); } } if (list.Count > 0) { GodsWarManagerment.Instance.mySuportInfo = list; } } if (callback != null) { callback(); MaskWindow.UnlockUI(); } }
public override void read(ErlKVMessage message) { ErlType erl = message.getValue("msg") as ErlType; if (erl is ErlArray) { GodsWarFinalUserInfo user; List <GodsWarFinalUserInfo> infos = new List <GodsWarFinalUserInfo>(); ErlArray erlarry = erl as ErlArray; for (int i = 0; i < erlarry.Value.Length; i++) { user = new GodsWarFinalUserInfo(); user.bytesRead(erlarry.Value[i] as ErlArray); infos.Add(user); } if (infos != null) { GodsWarManagerment.Instance.finalInfoList = infos; } if (callback != null) { callback(); } } else { MessageWindow.ShowAlert(erl.getValueString()); if (callback != null) { callback = null; } } }
/// <summary> /// 回调读取通讯 /// </summary> /// <param name="message">Message.</param> public override void read(ErlKVMessage message) { int index = 0; ErlType erlType = message.getValue("msg") as ErlType; if (erlType is ErlArray) { ErlArray arr = erlType as ErlArray; int huntType = StringKit.toInt(arr.Value [index++].getValueString()); if (huntType == StarSoulConfigManager.HUNT_MONEY_TYPE) // 普通裂魂 { huntStarSoul(index, arr); } else if (huntType == StarSoulConfigManager.HUNT_RMB_TYPE) // 钻石裂魂 { HuntStarSoulByRmb(index, arr); } } else { UiManager.Instance.openDialogWindow <MessageWindow> ((win) => { win.initWindow(1, LanguageConfigManager.Instance.getLanguage("s0093"), null, erlType.getValueString(), null); }); } }
public override void read(ErlKVMessage message) { Dictionary <int, int> map = new Dictionary <int, int>(); ErlArray array = message.getValue("msg") as ErlArray; if (array != null) { for (int i = 0; i < array.Value.Length; i += 2) { int sid = StringKit.toInt(array.Value[i].getValueString()); int num = StringKit.toInt(array.Value[i + 1].getValueString()); map.Add(sid, num); } } List <ArenaAwardSample> samples = ArenaAwardSampleManager.Instance.getSamplesByType(ArenaAwardWindow.TYPE_GUESS); List <ArenaAwardInfo> infos = new List <ArenaAwardInfo>(); foreach (ArenaAwardSample sample in samples) { ArenaAwardInfo info = new ArenaAwardInfo(); info.sample = sample; info.condition = map[sample.condition]; infos.Add(info); } if (callback != null) { callback(infos); } }
public static string erlArrToStr(ErlArray arr) { if (arr == null) { return string.Empty; } string str = string.Empty + '['; for (int i = 0; i < arr.Value.Length; i++) { ErlType type = arr.Value[i]; if (type != null) { string str2; if (type is ErlArray) { str2 = str; string[] textArray1 = new string[] { str2, "[\"", type.GetType().Name, "\",", erlArrToStr(type as ErlArray), "]" }; str = string.Concat(textArray1); } else { str2 = str; string[] textArray2 = new string[] { str2, "[\"", type.GetType().Name, "\",", type.getValueString(), "]" }; str = string.Concat(textArray2); } if (i < (arr.Value.Length - 1)) { str = str + ","; } } } return (str + "]"); }
public override void read(ErlKVMessage message) { ErlArray array = message.getValue("msg") as ErlArray; if (array != null) { List <RankItemMoney> list = new List <RankItemMoney>(); for (int i = 0; i < array.Value.Length; i++) { ErlArray ea = array.Value[i] as ErlArray; RankItemMoney item = new RankItemMoney(); item.uid = ea.Value[0].getValueString(); item.name = ea.Value[1].getValueString(); item.vipLevel = StringKit.toInt(ea.Value[2].getValueString()); item.money = StringKit.toInt(ea.Value[3].getValueString()); // if(item.vipLevel > 0) // item.name = "[VIP"+item.vipLevel+"]" + item.name; list.Add(item); } if (callback != null) { callback(list); } } }
public override void read(ErlKVMessage message) { ErlType type = message.getValue("msg") as ErlType; if (type is ErlArray) { ErlArray arr = type as ErlArray; int index = 0; int checkedPoint = StringKit.toInt(arr.Value[index++].getValueString()); int prizeSid = StringKit.toInt(arr.Value[index++].getValueString()); int prizeNum = StringKit.toInt(arr.Value[index++].getValueString()); if (callback != null) { callback(checkedPoint, prizeSid, prizeNum); } } else { MessageWindow.ShowAlert((message.getValue("msg") as ErlString).getValueString()); MaskWindow.UnlockUI(); if (callback != null) { callback = null; } } }
public static string[] ErlArray2String(ErlArray array) { string[] strArray = new string[array.Value.Length]; for (int i = 0; i < strArray.Length; i++) { strArray[i] = array.Value[i].getValueString(); } return strArray; }
public static int[] ErlArray2Int(ErlArray array) { int[] numArray = new int[array.Value.Length]; for (int i = 0; i < numArray.Length; i++) { numArray[i] = StringKit.toInt(array.Value[i].getValueString()); } return numArray; }
public static void Main(string[] args) { string get_storage_card = ConfigHelper.GetAppConfig("/yxzh/affiche/get_active_notice"); //get_storage_card = "['(clist)']"; get_storage_card=get_storage_card.Replace("'","\""); ErlType[] et = StringKit.strToErlTypeArray (get_storage_card); //ErlType[] et = StringKit.strToErlTypeArray ("[[[1,1,1],[1,1]],[1],[1]]", "[[[\"int\",\"int\",\"byte\"],[\"byte\",\"int\"]],[\"int\"],[\"byte\"]]"); ErlArray ea = new ErlArray (et); Log.Info (ea.getValueString()); }
public void readMessage(ErlKVMessage message) { string str = message.Cmd; Log.Info (str); Log.Info (message.toJsonString ()); BaseFPort bf = null; foreach (string key in BaseFPort.portDict.Keys) { if (key.Contains (str)||str.Contains(key)) { bf = BaseFPort.portDict [key]; } } if (bf != null) { bf.erlConnect = this.erlConnect; bf.read (message); } else { switch (str) { case "echo": ErlKVMessage _messag = new ErlKVMessage ("r_ok"); _messag.addValue (null, new ErlInt (message.getPort ())); base.send (this.erlConnect, _messag); break; case "/yxzh/home_port/get_info": ErlKVMessage msg = new ErlKVMessage ("r_ok"); msg.addValue (null, new ErlInt (message.getPort ())); msg.addValue ("msg", new ErlAtom ("home_not_open")); base.send (this.erlConnect, msg); break; case "/yxzh/ww_guild_child_fore_port/get_switch": ErlKVMessage msg1 = new ErlKVMessage ("r_ok"); msg1.addValue (null, new ErlInt (message.getPort ())); msg1.addValue ("msg", new ErlByte (1)); base.send (this.erlConnect, msg1); break; case "/yxzh/question/get_questions": case "/yxzh/week_award/init": case "/yxzh/expedition/get_base_info": case "/yxzh/opentask/get_opentasks": case "/yxzh/title/get_title": case "/yxzh/affiche/get_active_notice": //break; default: //Log.Error (message.Cmd); String strValue = ConfigHelper.GetAppConfig (message.Cmd); ErlKVMessage dmsg = new ErlKVMessage ("r_ok"); dmsg.addValue (null, new ErlInt (message.getPort ())); ErlType[] et = StringKit.strToErlTypeArray (strValue); ErlArray ea = new ErlArray (et); dmsg.addValue ("msg", ea); base.send (this.erlConnect, dmsg); break; } } }
public static ErlType complexAnalyse(ByteBuffer data) { int position = data.position; int num2 = data.readByte(); data.position = position; if ((num2 == ErlArray.TAG[0]) || (num2 == ErlArray.TAG[1])) { ErlArray array = new ErlArray(null); array.bytesRead(data); return array; } switch (num2) { case 0x6a: { ErlNullList list = new ErlNullList(); list.bytesRead(data); return list; } case 0x6c: { ErlList list2 = new ErlList(null); list2.bytesRead(data); return list2; } case 100: { ErlAtom atom = new ErlAtom(null); atom.bytesRead(data); return atom; } case 0x6b: { ErlString str = new ErlString(null); str.sampleBytesRead(data); return str; } case 110: { ErlLong @long = new ErlLong(); @long.bytesRead(data); return @long; } case 0x6d: { ErlByteArray array2 = new ErlByteArray(null); array2.bytesRead(data); return array2; } } return null; }
public override void read(ErlKVMessage message) { if (this.erlConnect != null) { //user 返回值 String strValue = ConfigHelper.GetAppConfig (message.Cmd); ErlKVMessage msg = new ErlKVMessage ("r_ok"); msg.addValue (null, new ErlInt (message.getPort ())); ErlType[] et = StringKit.strToErlTypeArray (strValue); ErlArray ea = new ErlArray (et); msg.addValue ("msg", ea); base.send (this.erlConnect, msg); } }
public override void read(ErlKVMessage message) { if (this.erlConnect != null) { string stype = (message.getValue ("type") as ErlString).Value; ErlKVMessage msg = new ErlKVMessage ("r_ok"); msg.addValue (null, new ErlInt (message.getPort ())); String strValue = ConfigHelper.GetAppConfig (message.Cmd +"_" + stype); ErlType[] et = StringKit.strToErlTypeArray (strValue); ErlArray ub = new ErlArray (et); msg.addValue ("msg", ub); base.send (this.erlConnect, msg); } }
public Chat(string uid, string name, int vip, int channelType, int sender, int stime, int isShow, int job, string content, ErlArray goods, string friendReceiveUid, string friendReceiveName, int friendReceiveVip, string areaInfo) { this.uid = uid; this.name = name; this.vip = vip; this.channelType = channelType; this.sender = sender; this.stime = stime; this.job = job; this.content = content; this.isShow = isShow; this.goods = goods; this.friendReceiveUid = friendReceiveUid; this.friendReceiveName = friendReceiveName; this.friendReceiveVip = friendReceiveVip; this.areaInfo = areaInfo; }
public override void read(ErlKVMessage message) { string str = message.Cmd; switch (str) { case "/yxzh/active_port/get_active_info": //ErlArray eaa = (message.getValue ("sid") as ErlType).getValueString (); String strValus = (message.getValue ("sid") as ErlType).getValueString (); if (strValus != null && strValus.Split(',').Length > 1) { strValus = ConfigHelper.GetAppConfig (message.Cmd); } else { strValus = (message.getValue ("sid") as ErlType).getValueString (); strValus = ConfigHelper.GetAppConfig(message.Cmd + "_" + strValus); } if (this.erlConnect != null) { // /yxzh/title/get_title 返回值 ErlKVMessage msg = new ErlKVMessage ("r_ok"); msg.addValue (null, new ErlInt (message.getPort ())); //String strValue = ConfigHelper.GetAppConfig (message.Cmd); ErlType[] et = StringKit.strToErlTypeArray (strValus); ErlArray ea = new ErlArray (et); msg.addValue ("msg", ea); base.send (this.erlConnect, msg); } break; case "/yxzh/active_port/get_text_notice": default: if (this.erlConnect != null) { // /yxzh/title/get_title 返回值 ErlKVMessage msg = new ErlKVMessage ("r_ok"); msg.addValue (null, new ErlInt (message.getPort ())); String strValue = ConfigHelper.GetAppConfig (message.Cmd); ErlType[] et = StringKit.strToErlTypeArray (strValue); ErlArray ea = new ErlArray (et); msg.addValue ("msg", ea); base.send (this.erlConnect, msg); Log.Debug (msg.toJsonString ()); } break; } }
public static void getErlType(string strValue, string strType,ErlArray ea ,Stack skValue ,Stack skType ) { string tmpValue = ""; string tmpType = ""; for (int i = 0; i < strValue.Length; i++) { if (strValue.Substring (i, 1) == "[") { skValue.Push(strValue.Substring(0,i+1)); tmpValue = strValue.Substring (i+1, strValue.Length - i-1); break; } } for (int i = 0; i < strType.Length; i++) { if (strType.Substring (i, 1) == "[") { skType.Push(strType.Substring(0,i+1)); tmpType = strType.Substring (i+1, strType.Length - i-1); break; } } }
public Boolean procCmd(int _port , BaseFPort fport) { if (needProcCmdDict.ContainsKey(_port)) { string cCmd = needProcCmdDict [_port]; if (FilterCmdDict [cCmd]._count >= FilterCmdDict [cCmd]._beginCount) { String strValue = ConfigHelper.GetAppConfig (cCmd); ErlKVMessage msg = new ErlKVMessage ("r_ok"); msg.addValue (null, new ErlInt (_port)); ErlType[] et = StringKit.strToErlTypeArray (strValue); ErlArray ea = new ErlArray (et); msg.addValue ("msg", ea); Log.Info(msg.Cmd+"|"+ msg.toJsonString()); ByteBuffer data = new ByteBuffer(); //data.writeBytes (mybak); msg.bytesWrite(data); data.top = (int)data.bytesAvailable; byte[] tmpdata= new byte[(int)data.bytesAvailable]; data.readBytes (tmpdata, 0, tmpdata.Length); fport.erlConnect.tmpBuffer.position = 0; Log.Info (fport.erlConnect.tmpBuffer) ; ByteBuffer tmp1 = new ByteBuffer(); tmp1.writeBytes (tmpdata); //this.erlConnect.send (this.erlConnect.tmpBuffer); if (fport.erlConnect.socket.Connected) { fport.send (fport.erlConnect, msg); } else { Log.Info ("客户端已断开不再回传"); } //base.erlConnect.socket.Send (bak); FilterCmdDict [cCmd]._count--; Log.Info ("处理完成的CMD[" + cCmd + "]"); return true ; } } return false; }
public override void read(ErlKVMessage message) { if (this.erlConnect != null) { //登陆成功返回值 ErlKVMessage msg = new ErlKVMessage ("r_ok"); msg.addValue ("msg", new ErlAtom ("login_ok")); msg.addValue (null, new ErlInt (message.getPort ())); base.send (this.erlConnect, msg); //guild 返回值 String strValue = ConfigHelper.GetAppConfig ("guild"); msg = new ErlKVMessage ("guild"); ErlType[] et = StringKit.strToErlTypeArray (strValue); ErlArray ea = new ErlArray (et); msg.addValue ("guild_skill", ea); base.send (this.erlConnect, msg); //chat 返回值 strValue = ConfigHelper.GetAppConfig ("chat"); msg = new ErlKVMessage ("chat"); et = StringKit.strToErlTypeArray (strValue); ea = new ErlArray (et); msg.addValue ("msg2", ea); base.send (this.erlConnect, msg); } }
public static void Main(string[] args) { Log.Info ("---------------"); String strValue = "abc(erlatom)"; //strValue = ConfigHelper.GetAppConfig ("/yxzh/mail/get_mails"); String strType = "string,string,byte,byte,int,int,string,int,byte,byte,byte,byte,int,byte,byte,byte,byte,byte,byte,byte,byte,string,string,"; strType = strType+"byte,byte,byte,byte,byte,byte,byte,string,byte,int,byte,int,int,int,byte,int,int,int,byte,byte,byte,int"; ErlType[] et = strToErlTypeArray (strValue); ErlArray ea = new ErlArray (et); Log.Info (ea.getValueString()); //Log.Info (ov); /* ErlType[] et = toErlTypeArray (strValue, strType, ','); ErlArray ea = new ErlArray (et); ErlString e = new ErlString ("dsf"); */ //e.bytesWrite //Log.Info (ea.getValueString ()); }
private int[] parseVipAwardSids(ErlArray sids) { int[] numArray = new int[sids.Value.Length]; for (int i = 0; i < sids.Value.Length; i++) { numArray[i] = StringKit.toInt(sids.Value[i].getValueString()); } return numArray; }
public void sendUser() { String strValue = ConfigHelper.GetAppConfig ("/yxzh/role/get_user"); ErlKVMessage msg = new ErlKVMessage ("r_ok"); msg.addValue (null, new ErlInt (messagePort)); ErlType[] et = StringKit.strToErlTypeArray (strValue); ErlArray ea = new ErlArray (et); msg.addValue ("msg", ea); base.send (this.erlConnect, msg); }
public override void erlReceive(Connect connect, ErlKVMessageClient message) { //this.readMessage (message); Log.Info(message.Cmd+"|"+ message.toJsonString()); if (messagePort == message.getPort()) { String strValue = ConfigHelper.GetAppConfig ("/yxzh/role/get_user"); ErlKVMessage msg = new ErlKVMessage ("r_ok"); msg.addValue (null, new ErlInt (message.getPort ())); ErlType[] et = StringKit.strToErlTypeArray (strValue); ErlArray ea = new ErlArray (et); msg.addValue ("msg", ea); base.send (this.erlConnect, msg); } if (message.Cmd == "/yxzh/role/get_user") { messagePort = message.getPort(); } }
private static ErlType[] getErlArr(List<object> jsonList) { ErlType[] typeArray = new ErlType[jsonList.Count]; for (int i = 0; i < jsonList.Count; i++) { List<object> list = jsonList[i] as List<object>; ErlType type = null; if ((list[0] as string) == typeof(ErlInt).Name) { type = new ErlInt(StringKit.toInt(list[1].ToString())); } else if ((list[0] as string) == typeof(ErlString).Name) { type = new ErlString(list[1].ToString()); } else if ((list[0] as string) == typeof(ErlByte).Name) { type = new ErlByte(byte.Parse(list[1].ToString())); } else if ((list[0] as string) == typeof(ErlAtom).Name) { type = new ErlAtom(list[1].ToString()); } else if ((list[0] as string) == typeof(ErlNullList).Name) { type = new ErlNullList(); } else if ((list[0] as string) == typeof(ErlArray).Name) { type = new ErlArray(getErlArr(list[1] as List<object>)); } typeArray[i] = type; } return typeArray; }
public static ErlType[] listToErlTypeArray(List<Object> list ) { ErlType[] et= new ErlType[list.Count ]; bool isList = false; if (list.Count > 0) { if (list [0].ToString () == "(erllist)") { et = new ErlType[list.Count - 1]; isList = true; list.RemoveAt (0); } }// = new ErlType[list.Count]; //string[] strTypeArray = strType.Split(','); int k = 0; for (int i = 0; i < list.Count; i++) { if (list [i].GetType ().Name.Contains ("List")) { List<Object> tmpList = list [i] as List<Object>; if (tmpList.Count > 0) { if (tmpList [0].ToString () == "(erlist)") { tmpList.RemoveAt (0); et [i] = new ErlList (listToErlTypeArray (tmpList)); } else { if (isList) { et [i] = new ErlList (listToErlTypeArray (tmpList)); } else { et [i] = new ErlArray ( listToErlTypeArray (tmpList)); } } } else { et [i] = new ErlArray (new ErlType[0]); } } else { string tmpstr = list [i].ToString (); string tmpType = "string"; if (tmpstr == "(erllist)") { isList = true; } else { if (list [i].GetType ().Name.ToLower ().Contains ("int")) { int count = StringKit.toInt (list [i].ToString ()); if (count < 255) { tmpType = "byte"; } else { tmpType = "int"; } } else if (tmpstr.ToLower ().Contains ("(erlatom)")) { tmpstr = tmpstr.Substring (0, tmpstr.Length - 9); tmpType = "atom"; } else if (tmpstr.ToLower ().Contains ("(clist)")) { tmpstr = tmpstr.Substring (0, tmpstr.Length - 7); tmpType = "clist"; } et [i] = toErlType (tmpstr, tmpType); } k ++; } } return et; }
public static ErlType toErlType(string strValue , string strType) { if (string.IsNullOrEmpty(strValue)) { return new ErlNullList(); } switch (strType) { case "atom": return new ErlAtom (strValue); case "string": return new ErlString (strValue); case "byte": return new ErlByte (toInt (strValue)); case "int": return new ErlInt (toInt (strValue)); case "double": return new ErlDouble (toLong(strValue)); case "clist": if (strValue.Length > 0) { char[] c = strValue.ToCharArray (); ErlInt[] eb = new ErlInt[c.Length]; for (int i = 0; i < c.Length; i++) { eb [i] = new ErlInt (c [i]); } ErlList el = new ErlList (eb); return el; } return new ErlNullList(); default : if (strType.Length>5&&strType.Substring (0, 4) == "list") { string tmpValue = strValue.Substring (1, strValue.Length - 2); string tmpType = strType.Substring (5, strType.Length - 6); ErlType[] list = toErlTypeArray (tmpValue,tmpType , ':'); ErlList elist = new ErlList (list); return elist; } if (strType.Length>6&&strType.Substring (0, 5) == "array") { string tmpValue = strValue.Substring (1, strValue.Length - 2); string tmpType = strType.Substring (6, strType.Length - 7); ErlType[] list = toErlTypeArray (tmpValue,tmpType , ':'); ErlArray elist = new ErlArray (list); return elist; } return new ErlNullList (); } }