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); }