private void RemoveBuff(IBuff buff) { int buffId = buff.GetBuffId(); OnBuffEventDispatch(EBuffActionType.RemoveBuff); buff.Release(); buffMap.Remove(buffId); }
private void HandlePBMessage(NetMessage msg) { if (msg.head.index == 0) { var helper = m_listNtfListener[msg.head.cmd]; if (helper != null) { object obj = PBSerializer.NDeserialize(msg.content, helper.TMsg); if (obj != null) { helper.onMsg.DynamicInvoke(obj); } else { Debuger.LogError("协议格式错误! cmd:{0}", msg.head.cmd); } } else { Debuger.LogError("未找到对应的监听者! cmd:{0}", msg.head.cmd); } } else { var helper = m_listRspListener[msg.head.index]; if (helper != null) { m_listRspListener.Remove(msg.head.index); object obj = PBSerializer.NDeserialize(msg.content, helper.TMsg); if (obj != null) { helper.onMsg.DynamicInvoke(obj); } else { Debuger.LogError("协议格式错误! cmd:{0}, index:{0}", msg.head.cmd, msg.head.index); } } else { Debuger.LogError("未找到对应的监听者! cmd:{0}, index:{0}", msg.head.cmd, msg.head.index); } } }
public bool StartServer(ServerModuleInfo info) { string fullName = ServerConfig.Namespace + "." + info.name + "." + info.name; Debuger.Log(fullName); try { Type type = Type.GetType(fullName + "," + info.assembly); var module = Activator.CreateInstance(type) as ServerModule; if (module != null) { module.Create(info); m_mapModule.Add(info.id, module); module.Start(); ServerConfig.SetServerModuleInfo(info); //处理缓存的消息 if (m_mapCacheMessage.ContainsKey(info.id)) { List <MessageObject> list = m_mapCacheMessage[info.id]; for (int i = 0; i < list.Count; i++) { MessageObject msgobj = list[i]; module.HandleMessage(msgobj.msg, msgobj.args); } m_mapCacheMessage.Remove(info.id); } return(true); } } catch (Exception e) { m_mapModule.Remove(info.id); Debuger.LogError("ServerModule[{0}] Create Or Start Error:{1}", info.name, e.Message + "\n" + e.StackTrace); } return(false); }
private void HandlePBMessage(NetMessage msg) { if (msg.head.index == 0) { var helper = m_listNtfListener[msg.head.cmd]; if (helper != null) { helper.msg = m_RecvBuff.DecodeProtoMsg(msg.content, helper.msg, helper.TMsg); if (helper.msg != null) { helper.onMsg.DynamicInvoke(helper.msg); } else { Debuger.LogError("协议格式错误! cmd:{0}", msg.head.cmd); } } else { Debuger.LogError("未找到对应的监听者! cmd:{0}", msg.head.cmd); } } else { var helper = m_listRspListener[msg.head.index]; if (helper != null) { m_listRspListener.Remove(msg.head.index); helper.msg = m_RecvBuff.DecodeProtoMsg(msg.content, helper.msg, helper.TMsg); if (helper.msg != null) { helper.onMsg.DynamicInvoke(helper.msg); } else { Debuger.LogError("协议格式错误! cmd:{0}, index:{0}", msg.head.cmd, msg.head.index); } } else { Debuger.LogError("未找到对应的监听者! cmd:{0}, index:{0}", msg.head.cmd, msg.head.index); } } }
public void UnRegisterService <T>() where T : class, IService { Type type = typeof(T); if (TryGetService(out T t)) { t.Release(); _map.Remove(type); } }
public void ReleaseGame(uint gameId) { Debuger.Log("gameId:{0}", gameId); FSPGame game = m_mapGame[gameId]; if (game != null) { game.Release(); m_mapGame.Remove(gameId); } }
public void StopServer(int id) { Debuger.Log(id); var moudule = m_mapModule[id]; if (moudule != null) { moudule.Stop(); moudule.Release(); m_mapModule.Remove(id); } }
public void ReleaseUserData(uint id) { m_mapUserData.Remove(id); }
private void HandlePBMessage(NetMessage msg) { Debuger.LogVerbose("msg.head:{0}", msg.head); if (msg.head.index == 0) { var helper = m_listNtfListener[msg.head.cmd]; if (helper != null) { object obj = null; try { obj = PBSerializer.NDeserialize(msg.content, helper.TMsg); } catch (Exception e) { Debuger.LogError("MsgName:{0}, msg.head:{0}", helper.TMsg.Name, msg.head); Debuger.LogError("DeserializeError:" + e.Message); } if (obj != null) { try { helper.onMsg1.DynamicInvoke(msg.head, obj); } catch (Exception e) { Debuger.LogError("MsgName:{0}, msg.head:{0}", helper.TMsg.Name, msg.head); Debuger.LogError("BusinessError:" + e.Message + "\n" + e.StackTrace); } } else { Debuger.LogError("协议格式错误! cmd:{0}", msg.head.cmd); } } else { Debuger.LogError("未找到对应的监听者! cmd:{0}", msg.head.cmd); } } else { var helper = m_listRspListener[msg.head.index]; if (helper != null) { m_listRspListener.Remove(msg.head.index); object obj = PBSerializer.NDeserialize(msg.content, helper.TMsg); if (obj != null) { helper.onMsg0.DynamicInvoke(msg.head.index, obj); } else { Debuger.LogError("协议格式错误! cmd:{0}, index:{0}", msg.head.cmd, msg.head.index); } } else { Debuger.LogError("未找到对应的监听者! cmd:{0}, index:{0}", msg.head.cmd, msg.head.index); } } }