MistMessage.MessageBlock.Builder mblockBuilder = MistMessage.MessageBlock.newBuilder();
mblockBuilder.mergeFrom(raw);
mBlock = mblockBuilder.build();
}
catch(Exception e) {
throw new MistException(MistException.UNABLE_TO_PARSE_MIST_MESSAGE);
}
// Unpack the attributes
dest = new Exchange(mBlock.getId());
if(mBlock.hasTtl()) {
props = new HashMap<String, String>();
ttl = mBlock.getTtl();
props.put(Session.MIST_MESSAGE_TTL, new Long(ttl).toString());
}
msg = mBlock.getMessage().toByteArray();
if(mBlock.getPropertiesCount() > 0) {
if(props == null)
props = new HashMap<String, String>();
for(KeyValuePair pair : mBlock.getPropertiesList())
props.put(pair.getKey(), pair.getValue());
}
for(MessageFilter filter : Daemon.messageFilters) {
filter.preSend(this);
}
if(msg.length > Daemon.MAX_TRANSMIT_MESSAGE_SIZE)
throw new MistException(MistException.sizeTooLarge(msg.length));
}