Changeset View
Changeset View
Standalone View
Standalone View
app/src/main/java/it/reyboz/bustorino/backend/mato/MQTTMatoClient.kt
| Show First 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | override fun connectionLost(cause: Throwable?) { | ||||
| // while(i < 20 && !isStarted) { | // while(i < 20 && !isStarted) { | ||||
| connect(context!!, object: IMqttActionListener{ | connect(context!!, object: IMqttActionListener{ | ||||
| override fun onSuccess(asyncActionToken: IMqttToken?) { | override fun onSuccess(asyncActionToken: IMqttToken?) { | ||||
| //relisten to messages | //relisten to messages | ||||
| for ((line,elms) in respondersMap.entries){ | for ((line,elms) in respondersMap.entries){ | ||||
| val topic = mapTopic(line) | val topic = mapTopic(line) | ||||
| if(elms.isEmpty()) | if(elms.isEmpty()) | ||||
| respondersMap.remove(line) | respondersMap.remove(line) | ||||
| else | else { | ||||
| client.subscribe(topic, QoS.AtMostOnce.value, null, null) | client.subscribe(topic, QoS.AtMostOnce.value, null, null) | ||||
| Log.d(DEBUG_TAG, "Resubscribed with topic $topic") | |||||
| } | |||||
| } | } | ||||
| Log.d(DEBUG_TAG, "Reconnected to MQTT Mato Client") | Log.d(DEBUG_TAG, "Reconnected to MQTT Mato Client") | ||||
| } | } | ||||
| override fun onFailure(asyncActionToken: IMqttToken?, exception: Throwable?) { | override fun onFailure(asyncActionToken: IMqttToken?, exception: Throwable?) { | ||||
| Log.w(DEBUG_TAG, "Failed to reconnect to MQTT server") | Log.w(DEBUG_TAG, "Failed to reconnect to MQTT server") | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | data class MQTTPositionUpdate( | ||||
| val longitude: Double, | val longitude: Double, | ||||
| val heading: Int?, | val heading: Int?, | ||||
| val speed: Int?, | val speed: Int?, | ||||
| val tripId: String?, | val tripId: String?, | ||||
| val direct: Int?, | val direct: Int?, | ||||
| val nextStop: Int?, | val nextStop: Int?, | ||||
| //val full: Int? | //val full: Int? | ||||
| ) | ) | ||||
| No newline at end of file | No newline at end of file | ||||
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register