private void Clear(NFunction f) { if (f != null) { functionCache.Remove(f.Id); } }
public bool Add(NFunction pf) { pf.Nm = this; functionList.Remove(pf); functionList.Add(pf); return(true); }
public override String GetMessageFuncName(int mid) { NFunction f = GetFunctin(mid); string name = ""; if (f != null) { name = f.Name; } return(name); }
public bool remove(uint id) { for (int i = 0; i < functionList.Count; i++) { NFunction o = functionList[i]; if (o.Id == id) { functionList.Remove(o); } } return(false); }
public NFunction GetFunction(uint id) { for (int i = 0; i < functionList.Count; i++) { NFunction o = functionList[i]; if (o.Id == id) { return(o); } } return(null); }
public override void Process(Package p) { int mid = p.MessageID; NFunction f = GetFunctin(mid); if (f != null && pprocess != null) { pprocess.Process(p.C, p, mid, f); } else { Logger.LogError("not find functioin msgid:" + mid); } }
public NFunction GetFunction(string pname) { if (pname == null) { return(null); } for (int i = 0; i < functionList.Count; i++) { NFunction o = functionList[i]; if (o.Name.CompareTo(pname) == 0) { return(o); } } return(null); }
bool Feild(uint k, Sio.SDataBuff d) { moduleKey t = (moduleKey)k; switch (t) { case moduleKey.module_name_key: name = d.stringValue; break; case moduleKey.module_startid: startID = d.uintValue; break; case moduleKey.module_endid: endID = d.uintValue; break; case moduleKey.module_function_list: { Sio.SListReader plist = d.listReader; Sio.SDataBuff tn = new Sio.SDataBuff(); while (plist.Next(tn)) { Sio.SMapReader pr = tn.mapReader; if (pr != null) { NFunction pf = new NFunction(); if (pf.Unsrial(pr)) { Add(pf); } } } } break; default: return(false); } return(true); }
public bool Unserial(Stream s) { if (s != null) { name = Core.Unity.Convert.ReadString(s); startID = Core.Unity.Convert.ReadUint(s); endID = Core.Unity.Convert.ReadUint(s); uint funsize = 0; funsize = Core.Unity.Convert.ReadUint(s); for (uint index = 0; index < funsize; ++index) { NFunction f = new NFunction(); if (f.Unserial(s)) { Add(f); } } return(true); } return(false); }
public bool Add(NModule m) { if (m != null) { Remove(m); moduelCache.Add(m); IList <NFunction> functionList = m.GetFunctionList(); for (int i = 0; i < functionList.Count; i++) { NFunction f = functionList[i]; if (functionCache.ContainsKey(f.Id)) { functionCache[f.Id] = f; } else { functionCache.Add(f.Id, f); } } return(true); } return(false); }
public bool Remove(NFunction pf) { pf.Nm = null; functionList.Remove(pf); return(true); }
public bool Process(Core.Net.Client c, Core.Net.Package p, int messageid, SNet.NFunction pf) { if (c.isConnected) { StringBuilder sb = new StringBuilder(); sb.Append(pf.Nm.Name); sb.Append("."); sb.Append(pf.Name); Logger.Log(string.Format("<color=#00ab00ff>>>>receive<<<,msgid:{0}({1})</color>", messageid, sb.ToString())); if (null != this.OnReceive) { this.OnReceive(messageid, p.Header.GetExtData(), p.Header.GetSeqNum()); } if (null != this.OnReceivePackage) { this.OnReceivePackage(messageid, p.Data); } // LuaFunction func = XLuaManager.Instance.GetLuaEnv().Global.Get<LuaFunction>(c.DispatchFunc); if (null != this.DispatchFunc) { var luaEnv = XLuaManager.Instance.GetLuaEnv(); var L = luaEnv.L; var translator = luaEnv.translator; int oldTop = LuaAPI.lua_gettop(L); int errFunc = LuaAPI.load_error_func(L, luaEnv.errorFuncRef); LuaAPI.lua_getref(L, this.DispatchFunc.GetLuaReference()); translator.PushAny(L, c.SocketID); translator.PushAny(L, messageid); translator.PushAny(L, p.Header.GetExtData()); translator.PushAny(L, p.Header.GetSeqNum()); translator.PushAny(L, sb.ToString()); int valueCount = 5; IList <NParam> param_list = pf.ParamList; if (p.Data != null) { MemoryStream ms = new MemoryStream(p.Data); for (int i = 0; i < param_list.Count; i++) { push_to_lua(param_list[i], ms, L); valueCount++; } } int error = LuaAPI.lua_pcall(L, valueCount, -1, errFunc); if (error != 0) { luaEnv.ThrowExceptionFromError(oldTop); } LuaAPI.lua_remove(L, errFunc); } } return(true); }