public bool Error(Core.Net.Client c, int etype) { ClientObject obj; ClientObject.cache_by_client.TryGetValue(c, out obj); this.OnError(obj, etype); return(true); }
public bool Close(Core.Net.Client c) { ClientObject obj; ClientObject.cache_by_client.TryGetValue(c, out obj); this.OnClose(obj); return(true); }
public bool ProcessEvent(Core.Net.Client c, Core.Net.Event.Type type, int error) { if (type == Core.Net.Event.Type.CONNECT) { return(Connection(c)); } else if (type == Core.Net.Event.Type.CLOSE) { Logger.LogError("Connect close ------------------------------------"); return(Close(c)); } else if (type == Core.Net.Event.Type.ERROR) { //Core.Game.GameManager.bDisconnect = true; return(Error(c, error)); } else { Logger.LogError("ProcessEvent() failed.. reason: unknown event type"); } 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); }