/** Sends out an array containing information about all the connected to the ccserver */ private void sendConnectedList() { // Setup some stuff ArrayList<ConnectionThread> currentConnections = parent.getConnectionThread(); ConnectionThread tempConnection; int size = currentConnections.size(); System.out.println(" Number of users: " + size); try { // Send packageID dos.writeByte(4); // Start sending to master how many entry's we will send dos.writeInt(size); for (int i = 0; i < size; i++) { tempConnection = currentConnections.get(i); // Send id dos.writeInt(tempConnection.getccserverId()); // Send name writeString(tempConnection.getComputerName()); // Send if in used dos.writeBoolean(tempConnection.isInUse()); // Send if thread is a master dos.writeBoolean(tempConnection.isMaster()); } } catch (IOException e) { parent.log.printlnErr("IO exception from thread #" + ccserverId + "@sendConnectionList"); e.printStackTrace(); } }
/** * This method will be called from the when a master wants to connect to a slave It will find the * right slave with the slaveID and then send the masters IP and port to the slave. * * @param slaveID the slaves id on the ccserver * @param IP the masters ip address * @param port the master port */ private void findAndConnectMasterToSlave(int slaveID, String IP, int port) { // First find the slave for (ConnectionThread ctSlave : parent.getConnectionThread()) { if (ctSlave.getccserverId() == slaveID) { // Now tell the slave to connect the the master ctSlave.connectSlaveToMaster(IP, port); break; } } }