mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-04 16:47:37 +08:00
[F] Fix other people disconnecting causing broadcast to crash
This commit is contained in:
@@ -27,6 +27,7 @@ data class ActiveClient(
|
||||
val socket: Socket,
|
||||
val reader: BufferedReader,
|
||||
val writer: BufferedWriter,
|
||||
val thread: Thread = Thread.currentThread(),
|
||||
// <Stream ID, Destination client stub IP>
|
||||
val tcpStreams: MutableMap<UInt, UInt> = mutableMapOf(),
|
||||
val pendingStreams: MutableSet<UInt> = mutableSetOf(),
|
||||
@@ -39,9 +40,16 @@ data class ActiveClient(
|
||||
|
||||
fun send(msg: Msg) {
|
||||
writeMutex.withLock {
|
||||
writer.write(msg.toString())
|
||||
writer.newLine()
|
||||
writer.flush()
|
||||
try {
|
||||
writer.write(msg.toString())
|
||||
writer.newLine()
|
||||
writer.flush()
|
||||
}
|
||||
catch (e: Exception) {
|
||||
log.error("Error sending message", e)
|
||||
socket.close()
|
||||
thread.interrupt()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user