private void marshallResponse(Response response, ObjectOutput out, Map<Object, Integer> refMap) throws IOException {
if (response instanceof RequestIgnoredResponse) {
out.writeByte(MAGICNUMBER_REQUEST_IGNORED_RESPONSE);
} else if (response instanceof ExtendedResponse) {
out.writeByte(MAGICNUMBER_EXTENDED_RESPONSE);
ExtendedResponse er = (ExtendedResponse) response;
out.writeBoolean(er.isReplayIgnoredRequests());
marshallObject(er.getResponse(), out, refMap);
} else if (response instanceof UnsuccessfulResponse) {
out.writeByte(MAGICNUMBER_UNSUCCESSFUL_RESPONSE);
} else if (response instanceof SuccessfulResponse) {
out.writeByte(MAGICNUMBER_SUCCESSFUL_RESPONSE);
marshallObject(((SuccessfulResponse) response).getResponseValue(), out, refMap);