Ejemplo n.º 1
0
 private void ProcessConnectionMessages(string messageType, string message)
 {
     if (ConnectionMessageUtils.GetType(messageType, out Type type))
     {
         ConnectionListener?.OnProcess(JsonUtility.FromJson(message, type), type);
     }
     else
     {
         Log.Error($"Unable to parse type: {messageType}");
     }
 }
Ejemplo n.º 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;
            }
        }