throws IOException
{
if (actorStream == null)
throw new IllegalStateException("HmtpReader.readPacket requires a valid ActorStream for callbacks");
JsonInput in = _in;
if (in == null)
return false;
String type = readString();
String to = readString();
String from = readString();
String payloadType = readString();
Class payloadClass = getPayloadClass(payloadType);
HmtpPacketType packetType = _typeMap.get(type);
if (packetType == null) {
throw new IllegalStateException("'" + type + "' is an unknown packet type");
}
switch (packetType) {
case MESSAGE:
{
Serializable value = (Serializable) in.readObject(payloadClass);
in.endPacket();
if (log.isLoggable(Level.FINER)) {
log.finer(this + " message " + value
+ " {to:" + to + ", from:" + from + "}");
}
actorStream.message(to, from, value);
break;
}
case MESSAGE_ERROR:
{
Serializable value = (Serializable) in.readObject();
BamError error = (BamError) in.readObject(BamError.class);
in.endPacket();
if (log.isLoggable(Level.FINER)) {
log.finer(this + " messageError " + error + " " + value
+ " {to:" + to + ", from:" + from + "}");
}
actorStream.messageError(to, from, value, error);
break;
}
case QUERY:
{
long id = in.readLong();
Serializable value = (Serializable) in.readObject();
in.endPacket();
if (log.isLoggable(Level.FINER)) {
log.finer(this + " query " + value
+ " {id:" + id + ", to:" + to + ", from:" + from + "}");
}
actorStream.query(id, to, from, value);
break;
}
case QUERY_RESULT:
{
long id = in.readLong();
Serializable value = (Serializable) in.readObject();
in.endPacket();
if (log.isLoggable(Level.FINER)) {
log.finer(this + " queryResult " + value
+ " {id:" + id + ", to:" + to + ", from:" + from + "}");
}
actorStream.queryResult(id, to, from, value);
break;
}
case QUERY_ERROR:
{
long id = in.readLong();
Serializable value = (Serializable) in.readObject();
BamError error = (BamError) in.readObject(BamError.class);
in.endPacket();
if (log.isLoggable(Level.FINER)) {
log.finer(this + " queryError " + error + " " + value
+ " {id:" + id + ", to:" + to + ", from:" + from + "}");
}