From 227ba127f8218ea93e846d7a98cb629458301c6f Mon Sep 17 00:00:00 2001 From: Ruakij Date: Mon, 29 Nov 2021 09:36:21 +0100 Subject: [PATCH] Extract packetType handling in own function --- src/streamHandler/PacketStreamFactory.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/streamHandler/PacketStreamFactory.js b/src/streamHandler/PacketStreamFactory.js index 2a7175d..6fd6bb8 100644 --- a/src/streamHandler/PacketStreamFactory.js +++ b/src/streamHandler/PacketStreamFactory.js @@ -88,6 +88,12 @@ class PacketStreamFactory extends Transform{ packet.bssid = data.match(/(?<=(^|\s)BSSID:).{17}(?=$|\s)/i)?.[0] ?? null; + packet = _handleHeaderPacketType(packet); + + return packet; + } + + _handleHeaderPacketType(packet){ // Cover special cases with more data let newPacket; switch(packet.packetType){ @@ -126,6 +132,12 @@ class PacketStreamFactory extends Transform{ packet.payloadData = hexConv.hexToBytes(data.match(/(?<=\s)([A-F0-9]{1,4}(?=\s))/igm)?.join('') ?? ''); packet.payloadData.splice(packet.payloadData.length-4, 4); // Remove FrameCheck sequence + packet = _handlePayloadPacketType(packet, data); + + return packet; + } + + _handlePayloadPacketType(packet) { // Cover special cases with more data let newPacket; switch(packet.packetType){