//--------------------------------------------------------------------- public Dictionary <string, string> getMapProp4All() { Dictionary <string, string> map_ret = new Dictionary <string, string>(); foreach (var prop in mMapProp) { map_ret[prop.Key] = EbJsonHelper.serialize(prop.Value.getValue()); } return(map_ret); }
void _loginComNode(int result, string data, string[] servers, Dictionary <string, object> param) { _tLoginResponseInfo lgRepInfo = EbJsonHelper.deserialize <_tLoginResponseInfo>(data); GateInfo gt = param["gateInfo"] as GateInfo; string path = param["path"] as string; if (gt.bloginComLock == false) { EbLog.Error("Error get unlock data: " + path); return; } mCoApp.onGateBack(lgRepInfo.server_group, lgRepInfo.acc, lgRepInfo.result, lgRepInfo.map_userdata); // 通知gate已经处理了数据. mCoApp.getZk().adelete(gt.loginLockComNode, null); }
//--------------------------------------------------------------------- public Dictionary <string, string> getMapProp4NetSync(byte current_nodetype, byte to_nodetype) { if (mMapProp.Count == 0) { return(null); } Dictionary <string, string> map_ret = new Dictionary <string, string>(); FieldInfo[] list_fieldinfo = GetType().GetFields(BindingFlags.Public | BindingFlags.Instance); foreach (var fi in list_fieldinfo) { if (!fi.FieldType.BaseType.Equals(typeof(IProp))) { continue; } Attribute[] attrs = System.Attribute.GetCustomAttributes(fi); foreach (Attribute attr in attrs) { if (!(attr is PropAttrDistribution)) { continue; } PropAttrDistribution a = (PropAttrDistribution)attr; if (a.NodePrimary == current_nodetype && a.NodeDistribution != null) { foreach (var i in a.NodeDistribution) { if (i == to_nodetype) { IProp p = (IProp)fi.GetValue(this); map_ret[p.getKey()] = EbJsonHelper.serialize(p.getValue()); break; } } } break; } } return(map_ret); }
//--------------------------------------------------------------------- public Prop <T> defProp <T>(Dictionary <string, string> map_param, string key, T default_value) { PropDef prop_def = new PropDef(key, typeof(T)); mMapPropDef[prop_def.getKey()] = prop_def; Prop <T> prop = new Prop <T>(prop_def, default_value); mMapProp[prop_def.getKey()] = prop; if (map_param != null && map_param.ContainsKey(prop_def.getKey())) { string json = map_param[prop_def.getKey()]; if (!string.IsNullOrEmpty(json.Trim())) { prop.set(EbJsonHelper.deserialize <T>(json)); } } return(prop); }
//----------------------------------------------------------------------------- public override string toJsonString() { return(EbJsonHelper.serialize(mValue)); }
//----------------------------------------------------------------------------- public override void fromJsonString(string json_str) { mValue = EbJsonHelper.deserialize <T>(json_str); }
//------------------------------------------------------------------------------------ public override void update(float elapsed_tm) { foreach (var svr in mLoginServer) { if (!svr.Value.bloginComLock && mLoginPlayer.Count > 0) { // 找到需要反馈给当前LoginServer的Player. var playerList = mLoginPlayer.Where(pl => pl.Value.LoginNodeId.Equals(svr.Value.id)); string LoginResult = ""; List <string> del = new List <string>(); foreach (var player in playerList) { // 将登陆结果通知应用层 string result = ""; Dictionary <byte, object> rt = null; if (mFuncOnLogin != null) { rt = mFuncOnLogin(player.Key, player.Value.AccountId, player.Value.TokenId, out result); } _tLoginResponseInfo info; info.acc = player.Key; info.server_group = player.Value.ServerGroup; info.result = "success"; info.map_userdata = rt; string seri = EbJsonHelper.serialize(info); //string singleInfo = string.Format("{0}:{1}:{2}:", player.Value.Account, player.Value.ServerGroup, "success"); LoginResult += seri; del.Add(player.Key); break; } foreach (var sigl in del) { mLoginPlayer.Remove(sigl); } if (LoginResult != "") { //LoginResult = LoginResult.Substring(0, LoginResult.Length - 1); // 去掉多余的分号. EbLog.Note("LoginResult:" + LoginResult); getZkClient().awriteData(svr.Value.loginComNode, LoginResult, null); getZkClient().acreate(svr.Value.loginLockComNode, "", ZK_CONST.ZOO_EPHEMERAL, null); svr.Value.bloginComLock = true; //break; } } if (!svr.Value.bofflineLock && mOfflineList.Count > 0) { string data = ""; while (mOfflineList.Count > 0) { data += mOfflineList.Dequeue() + ","; } getZkClient().awriteData(svr.Value.offlineNode, data, null); getZkClient().acreate(svr.Value.offlineLock, "", ZK_CONST.ZOO_EPHEMERAL, null); svr.Value.bofflineLock = true; } } }