Processing Net : avoid print disconnection message

IMO, library devs do a big disservice to the Processing community (who are very tweaky by nature :upside_down_face:) by using the keyword private or leaving the default package access level. :sneezing_face:

As we can confirm from class Server’s source code: :robot:

Both fields thread & server were left as package-protected access level. And many other fields as well btW! :roll_eyes:

We could use reflection to force access to them all. But it’s too convoluted & a hassle! :sleeping:

A much clever workaround is to make a “.java” file for our “hacked” Server subclass, which is HServer. :sunglasses:

And then “lie” that the “HServer.java” file belongs to packageprocessing.net” too! :smiling_imp:

All of a sudden all those package-protected members become accessible to our custom HServer subclass! :money_mouth_face:

Here’s my take on that: :innocent:

“HServer.java”

package processing.net;

import java.io.IOException;
import processing.core.PApplet;

public class HServer extends Server {
  public HServer(PApplet parent, int port) {
    this(parent, port, null);
  }

  public HServer(PApplet parent, int port, String host) {
    super(parent, port, host);
  }

  @Override public void dispose() {
    thread = null;

    if (clients != null) {
      disconnectAll();
      clientCount = 0;
      clients = null;
    }

    try {
      if (server != null) {
        server.close();
        server = null;
      }
    }

    catch (final IOException e) {
      //e.printStackTrace();
    }
  }
}