}
@Override
public void run() {
if (message instanceof OtpErlangTuple) {
MessageParser parser = new MessageParser();
IBinding parsed = parser.parse(message, "{ConversationID, set, Sender, FieldName, {Type, Value}}");
if (parsed.isValid()) {
if (parsed.getAtom("Type").equals("var")) {
OtpErlangObject valueE = parsed.getRaw("Value");
Object value = null;
if (valueE instanceof OtpErlangInt) {
try {
value = ((OtpErlangInt) valueE).intValue();
} catch (OtpErlangRangeException e) {
e.printStackTrace();
}
} else if (valueE instanceof OtpErlangString) {
value = ((OtpErlangString) valueE).stringValue();
} else if (valueE instanceof OtpErlangLong) {
value = ((OtpErlangLong) valueE).longValue();
if ((Long) value >= Integer.MIN_VALUE && (Long) value <= Integer.MAX_VALUE) {
value = new Integer(value.toString());
}
} else if (valueE instanceof OtpErlangDouble) {
value = ((OtpErlangDouble) valueE).doubleValue();
}
if (value != null) {
handlers.get(parsed.getAtom("FieldName")).Exec(value);
}
}
} else {
parsed = parser.parse(message, "{ConversationID, set_parent, Parent}");
if (parsed.isValid()) {
if (parsed.getRaw("Parent") instanceof OtpErlangTuple) {
parentRef.set((OtpErlangTuple)parsed.getRaw("Parent"));
}
}