mirror of
https://github.com/jwetzell/acn-js.git
synced 2026-08-16 03:53:22 +00:00
add sdt get sessions data decoding
This commit is contained in:
@@ -111,10 +111,14 @@ export type SDTAckData = {
|
||||
reliableSequenceNumber: number;
|
||||
};
|
||||
|
||||
export type SDTGetSessionsData = {
|
||||
componentID: string;
|
||||
};
|
||||
|
||||
export type SessionDataTransportPDU = {
|
||||
vector: SessionDataTransportVectors;
|
||||
// TODO(jwetzell): cleanup these types
|
||||
data: SDTJoinData | SDTJoinAcceptData | SDTJoinRefuseData | SDTWrapperData | SDTAckData | SDTLeavingData | Uint8Array;
|
||||
data: SDTJoinData | SDTJoinAcceptData | SDTJoinRefuseData | SDTWrapperData | SDTAckData | SDTLeavingData | SDTGetSessionsData | Uint8Array;
|
||||
};
|
||||
|
||||
export type SDTClientBlock = {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
Protocols,
|
||||
SDTAckData,
|
||||
SDTGetSessionsData,
|
||||
SDTJoinAcceptData,
|
||||
SDTJoinData,
|
||||
SDTJoinRefuseData,
|
||||
@@ -124,7 +125,7 @@ function decodeClientBlock(bytes: Uint8Array) {
|
||||
function decodeData(
|
||||
vector: SessionDataTransportVectors,
|
||||
bytes: Uint8Array
|
||||
): SDTJoinData | SDTJoinAcceptData | SDTJoinRefuseData | SDTWrapperData | SDTAckData | SDTLeavingData | Uint8Array {
|
||||
): SDTJoinData | SDTJoinAcceptData | SDTJoinRefuseData | SDTWrapperData | SDTAckData | SDTLeavingData | SDTGetSessionsData | Uint8Array {
|
||||
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
||||
switch (vector) {
|
||||
case SessionDataTransportVectors.JOIN: {
|
||||
@@ -209,6 +210,11 @@ function decodeData(
|
||||
reasonCode: view.getUint8(24),
|
||||
};
|
||||
}
|
||||
case SessionDataTransportVectors.GET_SESSIONS: {
|
||||
return {
|
||||
componentID: toHex(bytes.subarray(0, 16))
|
||||
}
|
||||
}
|
||||
default:
|
||||
console.error(`unhandled SDT vector: ${vector}`);
|
||||
return bytes;
|
||||
|
||||
Reference in New Issue
Block a user