Пример #1
0
 /**
  * sends a raw message
  *
  * @param message is a string with the message
  */
 public void sendRaw(String message) {
   try {
     writer.write(message);
     writer.newLine();
     writer.flush();
   } catch (SocketException e) {
     System.out.println("[Server] Tried to send message to disconnected client.");
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Пример #2
0
 /** Safely disconnects this ClientHandler from the Server */
 public void disconnect() {
   try {
     pool.removeFromAllQueues(this);
     if (game != null) {
       game.endGame(false); // End the game the client was in.
     }
     reader.close();
     writer.close();
     client.close();
     System.out.println("[Server] Debug (ClientHandler) - Client has disconnected.");
     pool.removeClient(name);
     connected = false;
   } catch (IOException e) {
     e.printStackTrace();
   }
 }