OnSuccessStream: StreamingEvent("onSuccessStream") class OnError(val code: StreamingErrorCode): StreamingEvent("onError") } SealedClassで
2つのイベント型を定義
fun sendEvent(context: ReactApplicationContext, event: StreamingEvent) { val body = event.toBodyMap() context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java) .emit(event.name, body) } sendEvent(context, StreamingEvent.OnError(StreamingErrorCode.RTMP_CONNECTION_FAILED_OR_CLOSED)) sendEvent(context, StreamingEvent.OnSuccessStream) イベントタイプごとにReadableMapを生成 する拡張関数
onErrorイベントの場合: { code: 1, message: “Failed to RTMP connection” } onSuccessStreamの場合: {}