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 42 Lines • ▼ Show 20 Lines | private fun connect(context: Context, iMqttActionListener: IMqttActionListener?){ | ||||
| val clientID = "mqtt-explorer-${getRandomString(8)}"//"mqttjs_${getRandomString(8)}" | val clientID = "mqtt-explorer-${getRandomString(8)}"//"mqttjs_${getRandomString(8)}" | ||||
| //notification = Notifications.makeMQTTServiceNotification(context) | //notification = Notifications.makeMQTTServiceNotification(context) | ||||
| client = MqttAndroidClient(context,SERVER_ADDR,clientID,Ack.AUTO_ACK) | client = MqttAndroidClient(context,SERVER_ADDR,clientID,Ack.AUTO_ACK) | ||||
| // WE DO NOT WANT A FOREGROUND SERVICE -> it's only more mayhem | // WE DO NOT WANT A FOREGROUND SERVICE -> it's only more mayhem | ||||
| // (and the positions need to be downloaded only when the app is shown) | // (and the positions need to be downloaded only when the app is shown) | ||||
| /*if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){ | // update, 2024-04: Google Play doesn't understand our needs, so we put back the notification | ||||
| // and add a video of it working as Google wants | |||||
| if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){ | |||||
| //we need a notification | //we need a notification | ||||
| Notifications.createLivePositionsChannel(context) | |||||
| val notific = Notifications.makeMQTTServiceNotification(context) | val notific = Notifications.makeMQTTServiceNotification(context) | ||||
| client.setForegroundService(notific) | client!!.setForegroundService(notific) | ||||
| notification=notific | notification=notific | ||||
| }*/ | } | ||||
| val options = MqttConnectOptions() | val options = MqttConnectOptions() | ||||
| //options.sslProperties = | //options.sslProperties = | ||||
| options.isCleanSession = true | options.isCleanSession = true | ||||
| val headersPars = Properties() | val headersPars = Properties() | ||||
| headersPars.setProperty("Origin","https://mato.muoversiatorino.it") | headersPars.setProperty("Origin","https://mato.muoversiatorino.it") | ||||
| headersPars.setProperty("Host","mapi.5t.torino.it") | headersPars.setProperty("Host","mapi.5t.torino.it") | ||||
| ▲ Show 20 Lines • Show All 332 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