示例#1
0
        protected override void ProcessNetMessage(string interfaceType, string messageType, string message)
        {
            InterfaceTypes type = NetMessageUtils.GetInterfaceType(interfaceType);

            switch (type)
            {
            case InterfaceTypes.Connection:
                ProcessConnectionMessages(messageType, message);
                break;

            case InterfaceTypes.Lobby:
                ProcessLobbyMessages(messageType, message);
                break;
            }
        }
示例#2
0
        //---- Read Messages
        //------------------
        protected override void ProcessNetMessage(string interfaceType, string messageType, string message)
        {
            Type   type;
            object netMessage = null;

            switch (NetMessageUtils.GetInterfaceType(interfaceType))
            {
            case InterfaceTypes.None:
                break;

            case InterfaceTypes.Connection:
                if (ConnectionListener == null)
                {
                    Log.Error("Connection listener is null, did you forget to set it?");
                    return;
                }

                if (!ConnectionMessageUtils.GetType(messageType, out type))
                {
                    Log.Error($"Unable to parse connection message type: {messageType}");
                    return;
                }
                netMessage = JsonUtility.FromJson(message, type);
                ConnectionListener.OnProcess(netMessage, type);
                break;

            case InterfaceTypes.Lobby:
                if (LobbyListener == null)
                {
                    Log.Error("Lobby listener is null, did you forget to set it?");
                    return;
                }

                if (!LobbyMessageUtils.GetType(messageType, out type))
                {
                    Log.Error($"Unable to get message type: {messageType} is it added to dictionary?");
                    return;
                }
                netMessage = JsonUtility.FromJson(message, type);
                LobbyListener.OnProcess(netMessage, type);
                break;
            }
        }