Add all BENNC message types with unit tests
This commit is contained in:
22
src/messages/subscribe.ts
Normal file
22
src/messages/subscribe.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { MessageTypes } from '../common'
|
||||
import { numberToUint16BE } from '../utilities/number'
|
||||
import { packOutgoingPacket } from './packet'
|
||||
|
||||
const MESSAGE_TYPE = numberToUint16BE(MessageTypes.Subscribe)
|
||||
|
||||
export interface SubscribeMessage {
|
||||
messageType: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an outgoing subscribe (0x0000) packet.
|
||||
* @param properties The properties for the message.
|
||||
* @returns An outgoing subscribe (0x0000) packet.
|
||||
*/
|
||||
export function packSubscribeMessage (properties: SubscribeMessage): Buffer {
|
||||
const data = numberToUint16BE(properties.messageType)
|
||||
return packOutgoingPacket({
|
||||
messageType: MESSAGE_TYPE,
|
||||
data: data
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user