if (msg instanceof SessionResponseMessage) {
rexProMessageAsBytes = serializer.serialize((SessionResponseMessage) msg, SessionResponseMessage.class);
} else if (msg instanceof ErrorResponseMessage) {
rexProMessageAsBytes = serializer.serialize((ErrorResponseMessage) msg, ErrorResponseMessage.class);
} else if (msg instanceof ScriptRequestMessage) {
rexProMessageAsBytes = serializer.serialize((ScriptRequestMessage) msg, ScriptRequestMessage.class);
} else if (msg instanceof SessionRequestMessage) {
rexProMessageAsBytes = serializer.serialize((SessionRequestMessage) msg, SessionRequestMessage.class);
} else if (msg instanceof ScriptResponseMessage) {
rexProMessageAsBytes = serializer.serialize((ScriptResponseMessage) msg, ScriptResponseMessage.class);
}