mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Client proxy cleanup
This commit is contained in:
parent
9ecfe6a3e7
commit
446b94604c
1 changed files with 5 additions and 7 deletions
|
|
@ -41,31 +41,29 @@ class MqttClientProxyManager {
|
|||
|
||||
if let host = host {
|
||||
let port = defaultServerPort
|
||||
let username = node.mqttConfig?.username
|
||||
let password = node.mqttConfig?.password
|
||||
let root = node.mqttConfig?.root?.count ?? 0 > 0 ? node.mqttConfig?.root : "msh"
|
||||
let prefix = root!
|
||||
topic = prefix + "/2/e" + "/#"
|
||||
// Require opt in to map report terms to connect
|
||||
if node.mqttConfig?.mapReportingEnabled ?? false && UserDefaults.mapReportingOptIn || !(node.mqttConfig?.mapReportingEnabled ?? false) {
|
||||
connect(host: host, port: port, useSsl: useSsl, username: username, password: password, topic: topic)
|
||||
connect(host: host, port: port, useSsl: useSsl, topic: topic, node: node)
|
||||
} else {
|
||||
delegate?.onMqttError(message: "MQTT Map Reporting Terms need to be accepted.")
|
||||
}
|
||||
}
|
||||
}
|
||||
func connect(host: String, port: Int, useSsl: Bool, username: String?, password: String?, topic: String?) {
|
||||
func connect(host: String, port: Int, useSsl: Bool, topic: String?, node: NodeInfoEntity) {
|
||||
guard !host.isEmpty else {
|
||||
delegate?.onMqttDisconnected()
|
||||
return
|
||||
}
|
||||
let clientId = "MeshtasticAppleMqttProxy-" + String(ProcessInfo().processIdentifier)
|
||||
let clientId = "MeshtasticAppleMqttProxy-" + (node.user?.userId ?? String(ProcessInfo().processIdentifier))
|
||||
mqttClientProxy = CocoaMQTT(clientID: clientId, host: host, port: UInt16(port))
|
||||
if let mqttClient = mqttClientProxy {
|
||||
mqttClient.enableSSL = useSsl
|
||||
mqttClient.allowUntrustCACertificate = true
|
||||
mqttClient.username = username
|
||||
mqttClient.password = password
|
||||
mqttClient.username = node.mqttConfig?.username
|
||||
mqttClient.password = node.mqttConfig?.password
|
||||
mqttClient.keepAlive = 60
|
||||
mqttClient.cleanSession = true
|
||||
if debugLog {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue