1.2.2 • Published 3 years ago

@mangar2/mqttversion v1.2.2

Weekly downloads
4
License
LGPL-3.0-or-later
Repository
github
Last release
3 years ago

Abstract

Contents

Meta

Global functions

connect

connect (version, options) => {Object}

Creates the objects to connect ot a broker

connect Parameters

NameTypeDescription
versionstringinterface version '1 . 0' or '0 . 0'
optionsObjectconnect options

options properties

NameTypeDescription
clientIdstringunique client identifier
hoststringhost name of the client host
portnumberport number of the clien listening port
cleanbooltrue , if the connection is cleaned up after disconnect
keepAlivenubmerkeep alive time in milliseconds

connect returns

TypeDescription
Object{ headers , payload , resultCheck ( result ) }

disconnect

disconnect (clientId) => {Object}

Creates the objects to disconnect from a broker

disconnect Parameters

NameTypeDescription
clientIdstringunique client identifier

disconnect returns

TypeDescription
Object{ headers , payload , resultCheck ( result ) }

onConnect

onConnect (headers, payload) => {Object}

Creates the return types for a connect request

onConnect Parameters

NameTypeDescription
headersObjectmessage headers
payloadObjectpayload to return

onConnect returns

TypeDescription
Object{ headers , payload , statusCode }

onDisconnect

onDisconnect (headers) => {Object}

creates the return types for a disconnect request

onDisconnect Parameters

NameTypeDescription
headersObjectmessage headers

onDisconnect returns

TypeDescription
Object{ headers , payload , statusCode }

onPublish

onPublish (headers) => {Object}

creates the return types for a receive message

onPublish Parameters

NameTypeDescription
headersObjectinput headers

onPublish returns

TypeDescription
Object{ headers , payload , statusCode , packetid }

onPubrel

onPubrel (headers) => {Object}

Creates the objects for a qos = 2 commit message "pubcomp"

onPubrel Parameters

NameTypeDescription
headersObjectpubrel message headers

onPubrel returns

TypeDescription
Object{ headers , payload , statusCode , packetid }

onSubscribe

onSubscribe (headers, qosArray) => {Object}

Creates the subscribe result objects

onSubscribe Parameters

NameTypeDescription
headersObjectinput headers
qosArrayArrayquality of service reply array

onSubscribe returns

TypeDescription
Object{ headers , payload , statusCode , packetid }

onUnsubscribe

onUnsubscribe (headers) => {Object}

creates the return types for a disconnect request

onUnsubscribe Parameters

NameTypeDescription
headersObjectmessage headers

onUnsubscribe returns

TypeDescription
Object{ headers , payload , statusCode , packetid }

publish

publish (version, token, message, qos, dup, retain, packetid) => {Object}

Creates the objects to publish to a client

publish Parameters

NameTypeDescription
versionstringinterface version ( '0 . 0' or '1 . 0' )
tokenstringconnection token
messageObjectpayload
qosnumberquality of service ( 0 , 1 , 2 )
dupnumberduplicate flag 1 ( true ) or 0 ( false ) . Identifies duplicate packages
retainnumberflag 1 ( true ) or 0 ( false ) . Requrests to retain the message
packetidnumberunique id of the package

publish returns

TypeDescription
Object{ headers , payload , resultCheck ( result ) }

pubrel

pubrel (version, token, packetid) => {Object}

creates the return types for a receive pubrel message

pubrel Parameters

NameTypeDescription
versionstringinterface version ( '0 . 0' or '1 . 0' )
tokenstringconnection token
packetidnumberof the packet ( must be the same id as send by publish ! )

pubrel returns

TypeDescription
Object{ headers , payload , resultCheck ( result ) }

subscribe

subscribe (version, topics, clientId, packetid) => {Object}

Subscribes to a client

subscribe Parameters

NameTypeDescription
versionstringinterface version ( '0 . 0' or '1 . 0' )
topicsObject{ topic : qos , . . . }
clientIdstringunique client identifier
packetidnumber, undefinedunique id of the package ( not used on version 0 . 0 )

subscribe returns

TypeDescription
Object{ headers , payload , resultCheck ( result ) }

unsubscribe

unsubscribe (version, topics, clientId, packetid) => {Object}

Creats the objects to unsubscribe from a client

unsubscribe Parameters

NameTypeDescription
versionstringinterface version ( '0 . 0' or '1 . 0' )
topicsArrayarray of topic strings
clientIdstringunique client identifier
packetidnumber, undefinedunique id of the package ( not used on version 0 . 0 )

unsubscribe returns

TypeDescription
Object{ headers , payload , resultCheck ( result ) }