// failcheck
if (messageClazz == null) { buf.resetReaderIndex(); return; }
// try retrieve the serialization filter
NettySerializationFilter filter = GWMessageSerializationRegistry.getFilter(messageClazz);
// failcheck
if (filter == null) { buf.resetReaderIndex(); return; }
// try create the message
Message message;
try
{
message = messageClazz.newInstance();
}
catch (InstantiationException | IllegalAccessException ex)
{
LOGGER.error("Could not create an instance of an message.", ex);
buf.resetReaderIndex();
return;
}
// dont forget to initialize the message
message.init(ctx.channel());
// try serialize the message
if (!filter.deserialize(buf, message))
{
buf.resetReaderIndex();
return;
}