@Override public void write(final Object message, final Writer writer) throws Exception {
//noinspection ChainOfInstanceofChecks
if (message instanceof Request) {
writer.writeByte(REQUEST);
final Request request = (Request)message;
serializer.write(request.context, writer);
serializer.write(request.serviceId, writer);
serializer.write(request.methodId, writer);
serializer.write((request.arguments == null) ? NO_ARGUMENTS : Arrays.asList(request.arguments), writer);
} else if (message instanceof ValueReply) {