add custom port through args
This commit is contained in:
parent
db1db1e519
commit
66c80fac5d
2 changed files with 22 additions and 5 deletions
|
@ -14,18 +14,27 @@ import {
|
|||
const log = log_from(import.meta);
|
||||
|
||||
async function main() {
|
||||
const args = parse_args(Deno.args);
|
||||
|
||||
log("Client starting.");
|
||||
const interface_ = await ServerInterface.connect(9999);
|
||||
new InputHandler(interface_.outputs).spin();
|
||||
const interface_ = await ServerInterface.connect(args.port);
|
||||
const display = new DisplayHandler(interface_.outputs);
|
||||
display.spin();
|
||||
new MsgHandler(interface_.inputs, display).spin();
|
||||
new InputHandler(interface_.outputs).spin();
|
||||
display.spin();
|
||||
log("Connected.");
|
||||
|
||||
interface_.outputs.send({ kind: "ping", content: { message: "Machin." } });
|
||||
log("Sent ping.");
|
||||
}
|
||||
|
||||
function parse_args(args: string[]) {
|
||||
const [port_] = args;
|
||||
let port = 9999;
|
||||
if (port_ !== undefined) port = parseInt(port_);
|
||||
return { port };
|
||||
}
|
||||
|
||||
class MsgHandler {
|
||||
receiver;
|
||||
display;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue