cleanup punchpkt
This commit is contained in:
+1
-11
@@ -1,9 +1,7 @@
|
||||
import { RemoteInfo } from "node:dgram";
|
||||
|
||||
import { Commands, CommandsByValue, ControlCommands } from "./datatypes.js";
|
||||
import { XqBytesDec } from "./func_replacements.js";
|
||||
import { hexdump } from "./hexdump.js";
|
||||
import { parse_PunchPkt, create_P2pRdy, SendListWifi, SendUsrChk, DevSerial } from "./impl.js";
|
||||
import { create_P2pRdy, SendListWifi, SendUsrChk, DevSerial } from "./impl.js";
|
||||
import { Session } from "./session.js";
|
||||
import { u16_swap, u32_swap } from "./utils.js";
|
||||
|
||||
@@ -36,19 +34,11 @@ export const handle_P2PRdy = (session: Session, _: DataView) => {
|
||||
export const makePunchPkt = (dev: DevSerial): DataView => {
|
||||
const len = dev.prefix.length + dev.suffix.length + 8;
|
||||
const outbuf = new DataView(new Uint8Array(0x14).buffer); // 8 = serial u64
|
||||
console.log(len, dev.prefix.length, dev.serialU64, dev.suffix.length);
|
||||
console.log(dev.prefix, dev.serialU64, dev.suffix);
|
||||
outbuf.add(0).writeString(dev.prefix);
|
||||
outbuf.add(4).writeU64(dev.serialU64);
|
||||
outbuf.add(8 + dev.prefix.length).writeString(dev.suffix);
|
||||
return create_P2pRdy(outbuf);
|
||||
};
|
||||
export const handle_PunchPkt = (session: Session, dv: DataView, rinfo: RemoteInfo) => {
|
||||
const dev = parse_PunchPkt(dv);
|
||||
session.eventEmitter.emit("connect", dev.devId, rinfo);
|
||||
console.log("connect????");
|
||||
session.send(makePunchPkt(dev));
|
||||
};
|
||||
|
||||
export const createResponseForControlCommand = (session: Session, dv: DataView): DataView[] => {
|
||||
const start_type = dv.add(8).readU16(); // 0xa11 on control; data starts here on DATA pkt
|
||||
|
||||
+2
-10
@@ -1,15 +1,7 @@
|
||||
import { createSocket, RemoteInfo } from "node:dgram";
|
||||
import { create_P2pAlive, DevSerial } from "./impl.js";
|
||||
import { Commands, CommandsByValue } from "./datatypes.js";
|
||||
import {
|
||||
handle_P2PAlive,
|
||||
handle_PunchPkt,
|
||||
handle_P2PRdy,
|
||||
handle_Drw,
|
||||
notImpl,
|
||||
noop,
|
||||
makePunchPkt,
|
||||
} from "./handlers.js";
|
||||
import { handle_P2PAlive, handle_P2PRdy, handle_Drw, notImpl, noop, makePunchPkt } from "./handlers.js";
|
||||
import { hexdump } from "./hexdump.js";
|
||||
import EventEmitter from "node:events";
|
||||
import { SendVideoResolution, SendStartVideo, SendWifiDetails } from "./impl.js";
|
||||
@@ -127,7 +119,7 @@ const startVideoStream = (s: Session) => {
|
||||
};
|
||||
|
||||
export const Handlers: Record<keyof typeof Commands, PacketHandler> = {
|
||||
PunchPkt: handle_PunchPkt,
|
||||
PunchPkt: notImpl,
|
||||
P2PAlive: handle_P2PAlive,
|
||||
P2pRdy: handle_P2PRdy,
|
||||
DrwAck: noop,
|
||||
|
||||
Reference in New Issue
Block a user