private void sendToClients(Serializable message) {
   try {
     ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
     ObjectSerializationOutputStream objectOutputStream =
         new ObjectSerializationOutputStream(byteArrayOutputStream);
     objectOutputStream.writeObject(message);
     objectOutputStream.flush();
     ByteBuffer payload = ByteBuffer.wrap(byteArrayOutputStream.toByteArray());
     channel.send(
         payload, new InetSocketAddress("233.233.233.233", 2666)); // Special mutlicast for clients
   } catch (IOException e) {
     System.out.println("Failed to send message");
     e
         .printStackTrace(); // To change body of catch statement use File | Settings | File
                             // Templates.
   }
 }
 private void sendMessage(Serializable message, short serverId) {
   try {
     if (serverId == id) { // Sending to myself.
       messageReceived(null, message);
     } else {
       ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
       ObjectSerializationOutputStream objectOutputStream =
           new ObjectSerializationOutputStream(byteArrayOutputStream);
       objectOutputStream.writeObject(message);
       objectOutputStream.flush();
       ByteBuffer payload = ByteBuffer.wrap(byteArrayOutputStream.toByteArray());
       channel.send(payload, serverSet.getServer(serverId));
     }
   } catch (IOException e) {
     System.out.println("Failed to send message");
     e
         .printStackTrace(); // To change body of catch statement use File | Settings | File
                             // Templates.
   } catch (Exception e) {
     e
         .printStackTrace(); // To change body of catch statement use File | Settings | File
                             // Templates.
   }
 }