mirror of
https://github.com/jwetzell/acn-js.git
synced 2026-08-19 13:23:58 +00:00
add sdt disconnect and disconnecting data decoding
This commit is contained in:
@@ -130,6 +130,12 @@ export type SDTConnectRefuseData = {
|
||||
refuseCode: number;
|
||||
};
|
||||
|
||||
export type SDTDisconnectData = SDTConnectData;
|
||||
export type SDTDisconnectingData = {
|
||||
protocolID: number;
|
||||
reasonCode: number;
|
||||
};
|
||||
|
||||
export type SDTGetSessionsData = {
|
||||
componentID: string;
|
||||
};
|
||||
@@ -149,6 +155,8 @@ export type SessionDataTransportPDU = {
|
||||
| SDTConnectData
|
||||
| SDTConnectAcceptData
|
||||
| SDTConnectRefuseData
|
||||
| SDTDisconnectData
|
||||
| SDTDisconnectingData
|
||||
| Uint8Array;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import {
|
||||
SDTConnectAcceptData,
|
||||
SDTConnectData,
|
||||
SDTConnectRefuseData,
|
||||
SDTDisconnectData,
|
||||
SDTDisconnectingData,
|
||||
SDTGetSessionsData,
|
||||
SDTJoinAcceptData,
|
||||
SDTJoinData,
|
||||
@@ -141,6 +143,8 @@ function decodeData(
|
||||
| SDTConnectData
|
||||
| SDTConnectAcceptData
|
||||
| SDTConnectRefuseData
|
||||
| SDTDisconnectData
|
||||
| SDTDisconnectingData
|
||||
| Uint8Array {
|
||||
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
||||
switch (vector) {
|
||||
@@ -241,6 +245,7 @@ function decodeData(
|
||||
lastMissedSequence: view.getUint32(28),
|
||||
};
|
||||
}
|
||||
case SessionDataTransportVectors.DISCONNECT:
|
||||
case SessionDataTransportVectors.CONNECT:
|
||||
case SessionDataTransportVectors.CONNECT_ACCEPT: {
|
||||
return {
|
||||
@@ -253,6 +258,12 @@ function decodeData(
|
||||
refuseCode: view.getUint8(4),
|
||||
};
|
||||
}
|
||||
case SessionDataTransportVectors.DISCONNECTING: {
|
||||
return {
|
||||
protocolID: view.getUint32(0),
|
||||
reasonCode: view.getUint8(4),
|
||||
};
|
||||
}
|
||||
default:
|
||||
console.error(`unhandled SDT vector: ${vector}`);
|
||||
return bytes;
|
||||
|
||||
Reference in New Issue
Block a user