serveProgram<M extends Model> static method

Future<BrowserTerminalHostServer> serveProgram<M extends Model>({
  1. InternetAddress? address,
  2. int port = 8080,
  3. String pagePath = '/',
  4. String webSocketPath = '/ws',
  5. String title = 'Artisanal Browser Host',
  6. String? pageHtml,
  7. required M modelBuilder(),
  8. ProgramOptions options = const ProgramOptions(altScreen: false, frameTick: false, signalHandlers: false),
})

Binds a browser host server that runs a fresh program per websocket.

Implementation

static Future<BrowserTerminalHostServer> serveProgram<M extends Model>({
  io.InternetAddress? address,
  int port = 8080,
  String pagePath = '/',
  String webSocketPath = '/ws',
  String title = 'Artisanal Browser Host',
  String? pageHtml,
  required M Function() modelBuilder,
  ProgramOptions options = const ProgramOptions(
    altScreen: false,
    frameTick: false,
    signalHandlers: false,
  ),
}) {
  return bind(
    address: address,
    port: port,
    pagePath: pagePath,
    webSocketPath: webSocketPath,
    title: title,
    pageHtml: pageHtml,
    onSession: (socket) async {
      await runProgram(
        modelBuilder(),
        options: options,
        host: ProgramHost.webSocket(socket),
      );
    },
  );
}