jsy-app/uni_modules/zy-mqtt/utssdk/interface.uts

29 lines
914 B
Plaintext
Raw Permalink Normal View History

2024-09-30 10:11:05 +08:00
export type MqttManagerOption = {
host : string,
clientId : string,
userName : string,
password : string,
cleanSession ?: boolean, // false 创建可持续会话前提是clientId一直保持不变
automaticReconnect ?: boolean,
heartBeat ?: Int,
timeOut ?: Int
}
type callbackType = (res : UTSJSONObject) => void
export function connect(option : MqttManagerOption, callback : callbackType) : void
export function subscribe(topic : string, qos : Int, callback : callbackType) : void
export function unSubscribe(topic : string, callback : callbackType) : void
export function publishMessage(topic : string, qos : Int, message : string, callback : callbackType) : void
export function disConnect(callback : callbackType) : void
export function onConnectLost(callback : callbackType) : void
export function onReconnect(callback : callbackType) : void
export function getConfig() : UTSJSONObject