mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-05-01 15:14:29 +02:00
Added a try catch to HandlePacket.
This commit is contained in:
parent
73b048d4c5
commit
0e64fa8d4c
@ -121,32 +121,32 @@ class SyncSession : IAuthorizable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun handlePacket(socketSession: SyncSocketSession, opcode: UByte, subOpcode: UByte, data: ByteBuffer) {
|
fun handlePacket(socketSession: SyncSocketSession, opcode: UByte, subOpcode: UByte, data: ByteBuffer) {
|
||||||
Logger.i(TAG, "Handle packet (opcode: ${opcode}, subOpcode: ${subOpcode}, data.length: ${data.remaining()})")
|
|
||||||
|
|
||||||
when (opcode) {
|
|
||||||
Opcode.NOTIFY_AUTHORIZED.value -> {
|
|
||||||
_remoteAuthorized = true
|
|
||||||
checkAuthorized()
|
|
||||||
}
|
|
||||||
Opcode.NOTIFY_UNAUTHORIZED.value -> {
|
|
||||||
_remoteAuthorized = false
|
|
||||||
_onUnauthorized(this)
|
|
||||||
}
|
|
||||||
//TODO: Handle any kind of packet (that is not necessarily authorized)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isAuthorized) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opcode != Opcode.DATA.value) {
|
|
||||||
Logger.w(TAG, "Unknown opcode received: (opcode = ${opcode}, subOpcode = ${subOpcode})}")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.i(TAG, "Received (opcode = ${opcode}, subOpcode = ${subOpcode}) (${data.remaining()} bytes)")
|
|
||||||
//TODO: Abstract this out
|
|
||||||
try {
|
try {
|
||||||
|
Logger.i(TAG, "Handle packet (opcode: ${opcode}, subOpcode: ${subOpcode}, data.length: ${data.remaining()})")
|
||||||
|
|
||||||
|
when (opcode) {
|
||||||
|
Opcode.NOTIFY_AUTHORIZED.value -> {
|
||||||
|
_remoteAuthorized = true
|
||||||
|
checkAuthorized()
|
||||||
|
}
|
||||||
|
Opcode.NOTIFY_UNAUTHORIZED.value -> {
|
||||||
|
_remoteAuthorized = false
|
||||||
|
_onUnauthorized(this)
|
||||||
|
}
|
||||||
|
//TODO: Handle any kind of packet (that is not necessarily authorized)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isAuthorized) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opcode != Opcode.DATA.value) {
|
||||||
|
Logger.w(TAG, "Unknown opcode received: (opcode = ${opcode}, subOpcode = ${subOpcode})}")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.i(TAG, "Received (opcode = ${opcode}, subOpcode = ${subOpcode}) (${data.remaining()} bytes)")
|
||||||
|
//TODO: Abstract this out
|
||||||
when (subOpcode) {
|
when (subOpcode) {
|
||||||
GJSyncOpcodes.sendToDevices -> {
|
GJSyncOpcodes.sendToDevices -> {
|
||||||
StateApp.instance.scopeOrNull?.launch(Dispatchers.Main) {
|
StateApp.instance.scopeOrNull?.launch(Dispatchers.Main) {
|
||||||
|
@ -274,7 +274,7 @@ class SyncSocketSession {
|
|||||||
_sendBuffer.asUByteArray()[4] = opcode
|
_sendBuffer.asUByteArray()[4] = opcode
|
||||||
_sendBuffer.asUByteArray()[5] = subOpcode
|
_sendBuffer.asUByteArray()[5] = subOpcode
|
||||||
|
|
||||||
//Logger.i(TAG, "Encrypting message (size = ${HEADER_SIZE})")
|
//Logger.i(TAG, "Encrypting message (opcode = ${opcode}, subOpcode = ${subOpcode}, size = ${HEADER_SIZE})")
|
||||||
|
|
||||||
val len = _cipherStatePair!!.sender.encryptWithAd(null, _sendBuffer, 0, _sendBufferEncrypted, 0, HEADER_SIZE)
|
val len = _cipherStatePair!!.sender.encryptWithAd(null, _sendBuffer, 0, _sendBufferEncrypted, 0, HEADER_SIZE)
|
||||||
//Logger.i(TAG, "Sending encrypted message (size = ${len})")
|
//Logger.i(TAG, "Sending encrypted message (size = ${len})")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user