Add all BENNC message types with unit tests

This commit is contained in:
Jack Hadrill
2022-02-06 20:34:13 +00:00
parent 7d1a0991e4
commit e758de7ef4
28 changed files with 708 additions and 12539 deletions

View File

@@ -0,0 +1,22 @@
import { MessageTypes } from '../common'
import { numberToUint16BE } from '../utilities/number'
import { packOutgoingPacket } from './packet'
const MESSAGE_TYPE = numberToUint16BE(MessageTypes.Unsubscribe)
export interface UnsubscribeMessage {
messageType: number
}
/**
* Create an outgoing unsubscribe (0xFFFF) packet.
* @param properties The properties for the message.
* @returns An outgoing unsubscribe (0xFFFF) packet.
*/
export function packUnsubscribeMessage (properties: UnsubscribeMessage): Buffer {
const data = numberToUint16BE(properties.messageType)
return packOutgoingPacket({
messageType: MESSAGE_TYPE,
data: data
})
}