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