fix: reconcile leave requests in realtime
This commit is contained in:
@@ -272,20 +272,22 @@ class DriverLiveSyncClient(
|
||||
|
||||
private fun subscribe(socket: WebSocket, socketId: String) {
|
||||
val id = synchronized(lock) { driverId } ?: return
|
||||
val channel = "private-driver-mobile.$id"
|
||||
val channels = listOf("private-driver-mobile.$id", "private-driver-mobile.0")
|
||||
|
||||
scope.launch {
|
||||
runCatching {
|
||||
val auth = gateway.broadcastAuth(socketId, channel).auth
|
||||
if (!isCurrentSocket(socket)) return@launch
|
||||
val payload = mapOf(
|
||||
"event" to "pusher:subscribe",
|
||||
"data" to mapOf(
|
||||
"channel" to channel,
|
||||
"auth" to auth,
|
||||
),
|
||||
)
|
||||
check(socket.send(gson.toJson(payload))) { "WebSocket send returned false" }
|
||||
channels.forEach { channel ->
|
||||
val auth = gateway.broadcastAuth(socketId, channel).auth
|
||||
if (!isCurrentSocket(socket)) return@launch
|
||||
val payload = mapOf(
|
||||
"event" to "pusher:subscribe",
|
||||
"data" to mapOf(
|
||||
"channel" to channel,
|
||||
"auth" to auth,
|
||||
),
|
||||
)
|
||||
check(socket.send(gson.toJson(payload))) { "WebSocket send returned false" }
|
||||
}
|
||||
}.onFailure { throwable ->
|
||||
AppDiagnostics.log("realtime_subscription_error: ${throwable.message ?: throwable::class.java.simpleName}")
|
||||
socket.close(1000, "subscription_failed")
|
||||
|
||||
@@ -52,6 +52,10 @@ class DriverSyncWorker(
|
||||
syncRepository.saveSyncStates(response)
|
||||
refreshed = true
|
||||
}
|
||||
DriverSyncRepository.SCOPE_LEAVE_CALENDAR -> {
|
||||
syncRepository.saveSyncStates(response)
|
||||
refreshed = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user