public void serialize(OutputBuffer buf) throws IOException { // buf.writeBoolean(isRaw); // buf.writeByte((byte)0); // version // // range check priority int priority = message.getPriority(); if (priority > Byte.MAX_VALUE) throw new IllegalStateException( "Priority must be in the range of " + Byte.MIN_VALUE + " to " + Byte.MAX_VALUE + ". Lower values are higher priority. Priority of " + message + " was " + priority + "."); if (priority < Byte.MIN_VALUE) throw new IllegalStateException( "Priority must be in the range of " + Byte.MIN_VALUE + " to " + Byte.MAX_VALUE + ". Lower values are higher priority. Priority of " + message + " was " + priority + "."); // buf.writeByte((byte)priority); // // buf.writeShort(message.getType()); message.serialize(buf); // System.out.println("PEM.serialize() message:"+message+" type:"+message.getType()); }
public PastryEndpointMessage(int address, RawMessage message, NodeHandle sender) { super(address); checkRawType(message); setSender(sender); this.message = message; // isRaw = true; setPriority(message.getPriority()); }
public static void checkRawType(RawMessage message) { if (message.getType() == 0) { if (!(message instanceof JavaSerializedMessage)) { throw new IllegalArgumentException( "Message " + message + " is raw, but its type is 0, this is only allowed by Java Serialized Messages."); } } }
/** * Returns the internal message * * @return the credentials. */ public Message getMessage() { if (message.getType() == 0) return ((JavaSerializedMessage) message).getMessage(); return message; }
/** *************** Raw Serialization ************************************** */ public short getType() { return message.getType(); }