protected void RPC_LobbyMsg(BitStream stream, LobbyMessageInfo info) { ELobbyMsgType msgType = ELobbyMsgType.Max; try { msgType = stream.Read <ELobbyMsgType>(); if (CheckHandler(msgType)) { msgHandlers[msgType](stream, info); } else if (LogFilter.logError) { Debug.LogWarningFormat("Message:[{0}]|[{1}] does not implement", msgType, GetType()); } } catch (Exception e) { if (LogFilter.logError) { Debug.LogErrorFormat("Message:[{0}]\r\n{1}\r\n{2}\r\n{3}", GetType(), msgType, e.Message, e.StackTrace); } } }
public void RegisterHandlerSafe(ELobbyMsgType msgType, Action <BitStream, LobbyMessageInfo> handler) { if (msgHandlers.ContainsKey(msgType)) { if (LogFilter.logError) { Debug.LogWarningFormat("Duplicate msg handler:{0}", msgType); } return; } if (LogFilter.logDev) { Debug.LogWarningFormat("Register msg handler:{0}", msgType); } msgHandlers.Add(msgType, handler); }
public void RegisterHandler(ELobbyMsgType msgType, Action <BitStream, LobbyMessageInfo> handler) { if (msgHandlers.ContainsKey(msgType)) { if (LogFilter.logWarn) { Debug.LogWarningFormat("Replace msg handler:{0}", msgType); } msgHandlers.Remove(msgType); } if (LogFilter.logDev) { Debug.LogWarningFormat("Register msg handler:{0}", msgType); } msgHandlers.Add(msgType, handler); }
public bool CheckHandler(ELobbyMsgType msgType) { return(null == msgHandlers ? false : msgHandlers.CheckHandler(msgType)); }
public bool CheckHandler(ELobbyMsgType msgType) { return(msgHandlers.ContainsKey(msgType)); }
public Action <BitStream, LobbyMessageInfo> this[ELobbyMsgType msgType] { get { return(msgHandlers[msgType]); } }