add client host parameter
This commit is contained in:
parent
66c80fac5d
commit
64dbc20f4a
1 changed files with 7 additions and 5 deletions
|
@ -17,7 +17,7 @@ async function main() {
|
||||||
const args = parse_args(Deno.args);
|
const args = parse_args(Deno.args);
|
||||||
|
|
||||||
log("Client starting.");
|
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);
|
const display = new DisplayHandler(interface_.outputs);
|
||||||
new MsgHandler(interface_.inputs, display).spin();
|
new MsgHandler(interface_.inputs, display).spin();
|
||||||
new InputHandler(interface_.outputs).spin();
|
new InputHandler(interface_.outputs).spin();
|
||||||
|
@ -29,10 +29,12 @@ async function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse_args(args: string[]) {
|
function parse_args(args: string[]) {
|
||||||
const [port_] = args;
|
const [host_, port_] = args;
|
||||||
|
let host = "localhost";
|
||||||
|
if (host_ !== undefined) host = host_;
|
||||||
let port = 9999;
|
let port = 9999;
|
||||||
if (port_ !== undefined) port = parseInt(port_);
|
if (port_ !== undefined) port = parseInt(port_);
|
||||||
return { port };
|
return { host, port };
|
||||||
}
|
}
|
||||||
|
|
||||||
class MsgHandler {
|
class MsgHandler {
|
||||||
|
@ -117,8 +119,8 @@ class ServerInterface {
|
||||||
this.outputs = outputs;
|
this.outputs = outputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async connect(port: number) {
|
static async connect(hostname: string, port: number) {
|
||||||
const connection = await Deno.connect({ port });
|
const connection = await Deno.connect({ hostname, port });
|
||||||
return await ServerInterface.init(connection);
|
return await ServerInterface.init(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue