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); }
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); } }