use of com.faforever.client.remote.domain.ServerMessage in project downlords-faf-client by FAForever.
the class FafServerAccessorImpl method parseServerObject.
private void parseServerObject(String jsonString) {
try {
ServerMessage serverMessage = gson.fromJson(jsonString, ServerMessage.class);
if (serverMessage == null) {
logger.debug("Discarding unimplemented server message: {}", jsonString);
return;
}
Class<?> messageClass = serverMessage.getClass();
while (messageClass != Object.class) {
messageListeners.getOrDefault(messageClass, Collections.emptyList()).forEach(consumer -> consumer.accept(serverMessage));
messageClass = messageClass.getSuperclass();
}
for (Class<?> type : ClassUtils.getAllInterfacesForClassAsSet(messageClass)) {
messageListeners.getOrDefault(messageClass, Collections.emptyList()).forEach(consumer -> consumer.accept(serverMessage));
}
} catch (JsonSyntaxException e) {
logger.warn("Could not deserialize message: " + jsonString, e);
}
}
Aggregations