Add get history message
continuous-integration/drone/push Build is running Details

This commit is contained in:
Jack Hadrill 2024-11-19 23:15:50 +00:00
parent 3a163df991
commit 386e8c3ed1
3 changed files with 20 additions and 9 deletions

View File

@ -8,5 +8,5 @@ export enum MessageTypes {
UserDataRequest = 0x0002, UserDataRequest = 0x0002,
UserDataResponse = 0x0003, UserDataResponse = 0x0003,
Keepalive = 0x0005, Keepalive = 0x0005,
Unsubscribe = 0xFFFF GetHistory = 0xfffe,
} }

View File

@ -1,9 +1,4 @@
import { packSubscribeMessage } from './messages/subscribe' import { packGetHistoryMessage } from "./messages/history";
import { packBasicMessage, unpackBasicMessage } from './messages/basic'
import { packUserDataRequestMessage, unpackUserDataRequestMessage } from './messages/userDataRequest'
import { packUserDataResponseMessage, unpackUserDataResponseMessage } from './messages/userDataResponse'
import { packKeepaliveMessage } from './messages/keepalive'
import { packUnsubscribeMessage } from './messages/unsubscribe'
export const packers = { export const packers = {
0x0000: packSubscribeMessage, 0x0000: packSubscribeMessage,
@ -11,8 +6,8 @@ export const packers = {
0x0002: packUserDataRequestMessage, 0x0002: packUserDataRequestMessage,
0x0003: packUserDataResponseMessage, 0x0003: packUserDataResponseMessage,
0x0005: packKeepaliveMessage, 0x0005: packKeepaliveMessage,
0xffff: packUnsubscribeMessage 0xfffe: packGetHistoryMessage,
} 0xffff: packUnsubscribeMessage,
export const unpackers = { export const unpackers = {
0x0001: unpackBasicMessage, 0x0001: unpackBasicMessage,

16
src/messages/history.ts Normal file
View File

@ -0,0 +1,16 @@
import { MessageTypes } from "../common";
import { numberToUint16BE } from "../utilities/number";
import { packOutgoingPacket } from "./packet";
const MESSAGE_TYPE = numberToUint16BE(MessageTypes.Keepalive);
/**
* Create an outgoing keepalive (0x0005) packet.
* @returns An outgoing keepalive (0x0005) packet.
*/
export function packGetHistoryMessage(): Uint8Array {
return packOutgoingPacket({
messageType: MESSAGE_TYPE,
data: new Uint8Array(0),
});
}