/** * Process a touch point birth by getting the groupID and gestures for the touch point. NULL * touchpoint means we have a driver failure * * @param touchPoint The new touch point. * @return whether a client has claimed this touchPoint as its own. */ private boolean processBirth(TouchPoint touchPoint) { List<ClientConnection> clients_to_remove = null; boolean isClaimed = false; for (int i = 0; i < main._clients.size(); i++) { ClientConnection client = main._clients.get(i); // Return if the client claims the touch point try { if (touchPoint == null) client.processError(EventType.DRIVER_NONE); else isClaimed = client.processBirth(touchPoint); if (isClaimed) break; } catch (IOException e) { // This occurs if there is a communication error // with the client. In this case, we will want // to remove the client. if (clients_to_remove == null) clients_to_remove = new ArrayList<ClientConnection>(); clients_to_remove.add(client); } } if (clients_to_remove != null) for (int i = 0; i < clients_to_remove.size(); i++) { main._clients.remove(clients_to_remove.get(i)); Logger.info("[GestureServer] Client Disconnected"); } return isClaimed; }
/** * @param socket * @throws IOException */ private void acceptClientConnection(Socket socket) throws IOException { Logger.info("[GestureServer] Client connection accepted"); ClientConnection cc = new ClientConnection(socket); main._clients.add(cc); if (main.ic == null) { cc.processError(EventType.DRIVER_NONE); } else { main.myState |= JmolGestureServerInterface.HAS_CLIENT; } }