mirror of https://github.com/hykilpikonna/AquaDX
[F] Fix other people disconnecting causing broadcast to crash
parent
7363bb307d
commit
830b10878e
|
@ -27,6 +27,7 @@ data class ActiveClient(
|
||||||
val socket: Socket,
|
val socket: Socket,
|
||||||
val reader: BufferedReader,
|
val reader: BufferedReader,
|
||||||
val writer: BufferedWriter,
|
val writer: BufferedWriter,
|
||||||
|
val thread: Thread = Thread.currentThread(),
|
||||||
// <Stream ID, Destination client stub IP>
|
// <Stream ID, Destination client stub IP>
|
||||||
val tcpStreams: MutableMap<UInt, UInt> = mutableMapOf(),
|
val tcpStreams: MutableMap<UInt, UInt> = mutableMapOf(),
|
||||||
val pendingStreams: MutableSet<UInt> = mutableSetOf(),
|
val pendingStreams: MutableSet<UInt> = mutableSetOf(),
|
||||||
|
@ -39,9 +40,16 @@ data class ActiveClient(
|
||||||
|
|
||||||
fun send(msg: Msg) {
|
fun send(msg: Msg) {
|
||||||
writeMutex.withLock {
|
writeMutex.withLock {
|
||||||
writer.write(msg.toString())
|
try {
|
||||||
writer.newLine()
|
writer.write(msg.toString())
|
||||||
writer.flush()
|
writer.newLine()
|
||||||
|
writer.flush()
|
||||||
|
}
|
||||||
|
catch (e: Exception) {
|
||||||
|
log.error("Error sending message", e)
|
||||||
|
socket.close()
|
||||||
|
thread.interrupt()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue