serveProgram<M extends Model> static method
Future<BrowserTerminalHostServer>
serveProgram<M extends Model>({
- InternetAddress? address,
- int port = 8080,
- String pagePath = '/',
- String webSocketPath = '/ws',
- String title = 'Artisanal Browser Host',
- String? pageHtml,
- required M modelBuilder(),
- 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),
);
},
);
}