/** The logic that runs in separate thread. Dispatching responses. */ public void run() { if (connection == null) { logger.error("No connection."); return; } try { connectionReader = new BufferedReader(new InputStreamReader(connection.getInputStream())); if (!connectionReader.readLine().contains("XiVO")) { logger.error("Error xivo with server!"); destroy(); return; } String line; while ((line = connectionReader.readLine()) != null || !stopped) { try { if (logger.isTraceEnabled()) logger.trace("Read from server:" + line); handle((JSONObject) JSONValue.parseWithException(line)); } catch (Throwable ex) { logger.error("Error parsing object:" + line, ex); } } } catch (IOException ex) { destroy(); } }