예제 #1
0
    public static ServerMessage ParseData(JObject data)
    {
        ServerMessage serverMessage = new ServerMessage();

        serverMessage.method = ServerMessageUtils.ExtractAndRemoveData(data, "Method");
        serverMessage.key    = ServerMessageUtils.ExtractAndRemoveData(data, "id");
        serverMessage.@class = ServerMessageUtils.ExtractAndRemoveData(data, "Class");
        serverMessage.values = ServerMessageUtils.ExtractJValues(data);

        return(serverMessage);
    }
예제 #2
0
    public void ProccessJson(JObject jObject)
    {
        try
        {
            ServerMessage serverMessage = ServerMessage.ParseData(jObject);

            Type       type       = Type.GetType(serverMessage.@class);
            MethodInfo methodInfo = type.GetMethod(serverMessage.method);

            ParameterInfo[] parameterInfos = methodInfo.GetParameters();

            Player player = PlayerListener.GetInstance().FindPlayer(Convert.ToInt16(serverMessage.key));

            List <object> functionParameters =
                ServerMessageUtils.CreateFunctionParameters(parameterInfos, serverMessage);

            Dispatcher.Instance.Invoke(() => InvokeMethod(methodInfo, player, functionParameters));
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }
    }