mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-06 08:42:32 -08:00
Slightly janky fix for send failure instantly cancelling SolarXR scope
Closes #1974
This commit is contained in:
1 file changed
+8
-1
@@ -101,8 +101,15 @@ suspend fun handleSolarXRBridge(
|
||||
// share: this collector handles one bundle at a time, and send drains the buffer
|
||||
val fbb = FlatBufferBuilder(256)
|
||||
val sendBuffer = Buffer()
|
||||
// If a client connected, sent a message, then immediately disconnected, we want to
|
||||
// stop trying to write but still read the last message, so we can't cancel immediately.
|
||||
// We'll end up dropping the connection since the messages flow finishes collection
|
||||
// when an error happens
|
||||
var writeFailed = false
|
||||
|
||||
bridge.outbound.on<MessageBundle> { bundle ->
|
||||
if (writeFailed) return@on
|
||||
|
||||
fbb.clear()
|
||||
fbb.finish(bundle.encode(JvmFlatBufferWriter(fbb)))
|
||||
sendBuffer.write(fbb.dataBuffer())
|
||||
@@ -110,7 +117,7 @@ suspend fun handleSolarXRBridge(
|
||||
send(sendBuffer)
|
||||
} catch (e: IOException) {
|
||||
AppLogger.solarxr.warn("Exception when sending bundle to $name: ${e.message}")
|
||||
cancel()
|
||||
writeFailed = true
|
||||
}
|
||||
}.launchIn(this)
|
||||
|
||||
|
||||
Reference in new issue
Block a user