this.notify();
}
// Get events while we're alive.
while (receiveThread != null && receiveThread.isAlive()) {
Event event = null;
try {
// p("Getting event...");
// Get next event from server
event = EventParser.parse(reader);
p("Event received " + event);
} catch (Throwable t) {
// Stop and report error.
// warn("Stop run() on exception", t);
if (listener != null) {
listener.onError("exception during receive: " + t);
}
break;
}
// Handle event by calling listener
if (event != null && listener != null) {
// p("received: " + event.toXML());
String eventType = event.getEventType();
if (eventType.equals(E_HEARTBEAT)) {
listener.onHeartbeat(event);
} else if (eventType.equals(E_DATA)) {
listener.onData(event);
} else if (eventType.equals(E_JOIN_LISTEN_ACK)) {
id = event.getField(P_ID);
} else if (eventType.equals(E_LISTEN_ACK)) {
p("Listen ack ok");
} else if (eventType.equals(E_REFRESH_ACK)) {
// ignore
} else if (eventType.equals(E_ABORT)) {