while (ts3.getSocket()!= null && ts3.getSocket().isConnected() && ts3.getIn() != null && !stop) {
try {
if (ts3.getIn().ready()) {
final String line = ts3.getIn().readLine();
if (!line.isEmpty()) {
Command c = ts3.getCommandList().peek();
if (line.startsWith("notify")) {
TS3Query.log.info("< [event] " + line);
new Thread(new Runnable() {
public void run() {
String arr[] = line.split(" ", 2);
ts3.getEventManager().fireEvent(arr[0],
arr[1]);
}
}).start();
} else if (c != null && c.isSent()) {
TS3Query.log
.info("[" + c.getName() + "] < " + line);
if (line.startsWith("error")) {
c.feedError(line.substring("error ".length()));
if (c.getError().getId() != 0) {
TS3Query.log.severe("[ERROR] "
+ c.getError());
}
c.setAnswered();
ts3.getCommandList().remove(c);
} else if (!line.isEmpty()) {
c.feed(line);
}
} else {
TS3Query.log.info("< " + line);
}
}