From 64dbc20f4add68dd4b9ef0ef5036bbced69a2406 Mon Sep 17 00:00:00 2001 From: Matthieu Jolimaitre Date: Wed, 10 Apr 2024 10:35:04 +0200 Subject: [PATCH] add client host parameter --- client/main.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/client/main.ts b/client/main.ts index 1ca93fc..102423f 100755 --- a/client/main.ts +++ b/client/main.ts @@ -17,7 +17,7 @@ async function main() { const args = parse_args(Deno.args); log("Client starting."); - const interface_ = await ServerInterface.connect(args.port); + const interface_ = await ServerInterface.connect(args.host, args.port); const display = new DisplayHandler(interface_.outputs); new MsgHandler(interface_.inputs, display).spin(); new InputHandler(interface_.outputs).spin(); @@ -29,10 +29,12 @@ async function main() { } function parse_args(args: string[]) { - const [port_] = args; + const [host_, port_] = args; + let host = "localhost"; + if (host_ !== undefined) host = host_; let port = 9999; if (port_ !== undefined) port = parseInt(port_); - return { port }; + return { host, port }; } class MsgHandler { @@ -117,8 +119,8 @@ class ServerInterface { this.outputs = outputs; } - static async connect(port: number) { - const connection = await Deno.connect({ port }); + static async connect(hostname: string, port: number) { + const connection = await Deno.connect({ hostname, port }); return await ServerInterface.init(connection); }