allow onLogin CB to be specified

This commit is contained in:
DavidVentura
2024-01-31 16:32:06 +01:00
parent f7eb287d5b
commit 9685f8008e
4 changed files with 20 additions and 9 deletions
+9 -4
View File
@@ -1,11 +1,16 @@
import { createWriteStream } from "node:fs";
import http from "node:http";
import { RemoteInfo } from "dgram";
import { Handlers, makeSession, Session } from "./session.js";
import { Handlers, makeSession, Session, startVideoStream } from "./session.js";
import { discoverDevices } from "./discovery.js";
import { DevSerial } from "./impl.js";
const opts = { debug: false, ansi: false };
const opts = {
debug: false,
ansi: false,
discovery_ip: "192.168.40.101", //, "192.168.1.255";
};
let BOUNDARY = "a very good boundary line";
let responses = [];
@@ -38,13 +43,13 @@ const server = http.createServer((req, res) => {
});
let devEv = discoverDevices(opts);
devEv.on("discover", (rinfo, dev: DevSerial) => {
devEv.on("discover", (rinfo: RemoteInfo, dev: DevSerial) => {
if (dev.devId in sessions) {
console.log(`ignoring ${dev.devId} - ${rinfo.address}`);
return;
}
console.log(`discovered ${dev.devId} - ${rinfo.address}`);
const s = makeSession(Handlers, dev, rinfo, opts);
const s = makeSession(Handlers, dev, rinfo, startVideoStream, opts);
const withAudio = false;
s.eventEmitter.on("frame", (frame: Buffer) => {
let s = `--${BOUNDARY}\r\n`;