예제 #1
0
    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);
            }
        }
    }
예제 #2
0
    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);
    }
예제 #3
0
    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);
    }
예제 #4
0
 public bool CheckHandler(ELobbyMsgType msgType)
 {
     return(null == msgHandlers ? false : msgHandlers.CheckHandler(msgType));
 }
예제 #5
0
 public bool CheckHandler(ELobbyMsgType msgType)
 {
     return(msgHandlers.ContainsKey(msgType));
 }
예제 #6
0
 public Action <BitStream, LobbyMessageInfo> this[ELobbyMsgType msgType] {
     get { return(msgHandlers[msgType]); }
 }