configureLogging();
try {
int port = (args.length > 0) ? Integer.parseInt(args[0]) : 8888;
final Logger logger = Logger.getLogger(EndpointService.class.getName());
logger.log(Level.FINE, "Starting on port " + port);
HttpServer httpd = new NormalHttpServer(port,
new EndpointService(new Endpoint() {
public boolean acceptSubscriptionChange(String mode, String topic, String token, int leaseSeconds) {
System.out.println("Subscription change: "+mode+", "+topic+", "+token+", "+leaseSeconds);
return true;
}
public void handleDelivery(String topic, byte[] body) {
System.out.println("Received message:\n\"" + new String(body) + "\"");
}
}));
httpd.serve();
} catch (Exception e) {
e.printStackTrace();
}
}