Class WebUi

java.lang.Object
protocols.apps.canvas.ui.WebUi

public final class WebUi extends Object
A tiny embedded web UI for the canvas, built on the JDK's bundled HttpServer so the demo pulls in no HTTP dependency. It serves three static assets from the classpath (/web/index.html, app.js, style.css) and two JSON endpoints:
  • GET /api/state — the current canvas grid + this node's active-view neighbours, which the page polls a few times a second;
  • POST /api/paint{"x":..,"y":..,"color":0xRRGGBB} → paints one cell (which then disseminates by gossip like any other).

Handlers run on the server's own small thread pool and call back into CanvasApp.paintFromUi(int, int, int) / CanvasApp.stateJson(), both of which are safe off the event loop (see CanvasApp's threading note).

  • Constructor Details

    • WebUi

      public WebUi(int port, CanvasApp app)
  • Method Details

    • start

      public void start() throws IOException
      Bind and start serving. Throws if the port is unavailable.
      Throws:
      IOException
    • stop

      public void stop()