mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-07-18 23:12:07 +00:00
Synchronized writes.
This commit is contained in:
parent
176814a715
commit
698725d611
1 changed files with 30 additions and 27 deletions
|
@ -90,6 +90,7 @@ class FCastCastingDevice : CastingDevice {
|
|||
private var _thread: Thread? = null
|
||||
private var _pingThread: Thread? = null
|
||||
private var _lastPongTime = -1L
|
||||
private var _outputStreamLock = Object()
|
||||
|
||||
constructor(name: String, addresses: Array<InetAddress>, port: Int) : super() {
|
||||
this.name = name;
|
||||
|
@ -476,6 +477,7 @@ class FCastCastingDevice : CastingDevice {
|
|||
}
|
||||
|
||||
private fun send(opcode: Opcode, message: String? = null) {
|
||||
synchronized (_outputStreamLock) {
|
||||
try {
|
||||
val data: ByteArray = message?.encodeToByteArray() ?: ByteArray(0)
|
||||
val size = 1 + data.size
|
||||
|
@ -506,6 +508,7 @@ class FCastCastingDevice : CastingDevice {
|
|||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun <reified T> send(opcode: Opcode, message: T) {
|
||||
try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue