Import scripts/transport-bench/native-websocket-bench.kt.txt

This commit is contained in:
QQ 2026-11-17 09:20:44 +08:00
parent 13d8f21e8d
commit 1a52913f5b
1 changed files with 7 additions and 0 deletions

View File

@ -0,0 +1,7 @@
// Injected only by the independent benchmark builder; not a production API.
Function("sendSocket") { socketId: Int, payload: ByteArray ->
require(socketId >= 0 && payload.isNotEmpty() && payload.size <= 65535)
val context = appContext.reactContext as? ReactApplicationContext
val module = requireNotNull(context?.getNativeModule(com.facebook.react.modules.websocket.WebSocketModule::class.java))
module.sendBinary(payload.toByteString(), socketId)
}