mirror of
https://github.com/jwetzell/acn-js.git
synced 2026-09-02 03:58:59 +00:00
add sdt connect, connect accept, connect refuse data decoding
This commit is contained in:
@@ -120,6 +120,16 @@ export type SDTNakData = {
|
||||
lastMissedSequence: number;
|
||||
};
|
||||
|
||||
export type SDTConnectData = {
|
||||
protocolID: number;
|
||||
};
|
||||
|
||||
export type SDTConnectAcceptData = SDTConnectData;
|
||||
export type SDTConnectRefuseData = {
|
||||
protocolID: number;
|
||||
refuseCode: number;
|
||||
};
|
||||
|
||||
export type SDTGetSessionsData = {
|
||||
componentID: string;
|
||||
};
|
||||
@@ -136,6 +146,9 @@ export type SessionDataTransportPDU = {
|
||||
| SDTLeavingData
|
||||
| SDTGetSessionsData
|
||||
| SDTNakData
|
||||
| SDTConnectData
|
||||
| SDTConnectAcceptData
|
||||
| SDTConnectRefuseData
|
||||
| Uint8Array;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import {
|
||||
Protocols,
|
||||
SDTAckData,
|
||||
SDTConnectAcceptData,
|
||||
SDTConnectData,
|
||||
SDTConnectRefuseData,
|
||||
SDTGetSessionsData,
|
||||
SDTJoinAcceptData,
|
||||
SDTJoinData,
|
||||
@@ -135,6 +138,9 @@ function decodeData(
|
||||
| SDTLeavingData
|
||||
| SDTGetSessionsData
|
||||
| SDTNakData
|
||||
| SDTConnectData
|
||||
| SDTConnectAcceptData
|
||||
| SDTConnectRefuseData
|
||||
| Uint8Array {
|
||||
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
||||
switch (vector) {
|
||||
@@ -235,6 +241,18 @@ function decodeData(
|
||||
lastMissedSequence: view.getUint32(28),
|
||||
};
|
||||
}
|
||||
case SessionDataTransportVectors.CONNECT:
|
||||
case SessionDataTransportVectors.CONNECT_ACCEPT: {
|
||||
return {
|
||||
protocolID: view.getUint32(0),
|
||||
};
|
||||
}
|
||||
case SessionDataTransportVectors.CONNECT_REFUSE: {
|
||||
return {
|
||||
protocolID: view.getUint32(0),
|
||||
refuseCode: view.getUint8(4),
|
||||
};
|
||||
}
|
||||
default:
|
||||
console.error(`unhandled SDT vector: ${vector}`);
|
||||
return bytes;
|
||||
|
||||
Reference in New Issue
Block a user