@100mslive/react-native-hms 1.9.12 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/reactnativehmssdk/HMSHLSPlayer.kt +0 -15
- package/android/src/main/java/com/reactnativehmssdk/HMSManager.kt +38 -0
- package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +38 -0
- package/android/src/main/java/com/reactnativehmssdk/Interactivity/HMSInteractivityDecoder.kt +85 -0
- package/android/src/main/java/com/reactnativehmssdk/Interactivity/HMSRNInteractivityCenter.kt +39 -61
- package/ios/HMSInteractivityDecoder.swift +50 -0
- package/ios/HMSManager.m +9 -0
- package/ios/HMSManager.swift +19 -1
- package/ios/HMSRNInteractivityCenter.swift +31 -0
- package/ios/HMSRNSDK.swift +34 -0
- package/lib/commonjs/classes/HMSHLSTimedMetadata.js +2 -0
- package/lib/commonjs/classes/HMSHLSTimedMetadata.js.map +1 -0
- package/lib/commonjs/classes/HMSInteractivityCenter.js +21 -0
- package/lib/commonjs/classes/HMSInteractivityCenter.js.map +1 -1
- package/lib/commonjs/classes/HMSInteractivityEncoder.js +46 -2
- package/lib/commonjs/classes/HMSInteractivityEncoder.js.map +1 -1
- package/lib/commonjs/classes/HMSSDK.js +13 -0
- package/lib/commonjs/classes/HMSSDK.js.map +1 -1
- package/lib/commonjs/classes/polls/DecodedPollLeaderboardResponse.js +6 -0
- package/lib/commonjs/classes/polls/DecodedPollLeaderboardResponse.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPoll.js.map +1 -1
- package/lib/commonjs/classes/polls/HMSPollCreateParams.js.map +1 -1
- package/lib/commonjs/classes/polls/HMSPollLeaderboardEntry.js +6 -0
- package/lib/commonjs/classes/polls/HMSPollLeaderboardEntry.js.map +1 -0
- package/lib/commonjs/classes/polls/HMSPollLeaderboardSummary.js +2 -0
- package/lib/commonjs/classes/polls/HMSPollLeaderboardSummary.js.map +1 -0
- package/lib/commonjs/classes/polls/PollLeaderboardResponse.js +6 -0
- package/lib/commonjs/classes/polls/PollLeaderboardResponse.js.map +1 -0
- package/lib/commonjs/components/HMSHLSPlayer/HMSHLSPlayer.js +2 -10
- package/lib/commonjs/components/HMSHLSPlayer/HMSHLSPlayer.js.map +1 -1
- package/lib/commonjs/index.js +24 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/classes/HMSHLSTimedMetadata.js +2 -0
- package/lib/module/classes/HMSHLSTimedMetadata.js.map +1 -0
- package/lib/module/classes/HMSInteractivityCenter.js +21 -0
- package/lib/module/classes/HMSInteractivityCenter.js.map +1 -1
- package/lib/module/classes/HMSInteractivityEncoder.js +46 -2
- package/lib/module/classes/HMSInteractivityEncoder.js.map +1 -1
- package/lib/module/classes/HMSSDK.js +13 -0
- package/lib/module/classes/HMSSDK.js.map +1 -1
- package/lib/module/classes/polls/DecodedPollLeaderboardResponse.js +2 -0
- package/lib/module/classes/polls/DecodedPollLeaderboardResponse.js.map +1 -0
- package/lib/module/classes/polls/HMSPoll.js.map +1 -1
- package/lib/module/classes/polls/HMSPollCreateParams.js.map +1 -1
- package/lib/module/classes/polls/HMSPollLeaderboardEntry.js +2 -0
- package/lib/module/classes/polls/HMSPollLeaderboardEntry.js.map +1 -0
- package/lib/module/classes/polls/HMSPollLeaderboardSummary.js +2 -0
- package/lib/module/classes/polls/HMSPollLeaderboardSummary.js.map +1 -0
- package/lib/module/classes/polls/PollLeaderboardResponse.js +2 -0
- package/lib/module/classes/polls/PollLeaderboardResponse.js.map +1 -0
- package/lib/module/components/HMSHLSPlayer/HMSHLSPlayer.js +3 -11
- package/lib/module/components/HMSHLSPlayer/HMSHLSPlayer.js.map +1 -1
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/classes/HMSHLSTimedMetadata.d.ts +4 -0
- package/lib/typescript/classes/HMSInteractivityCenter.d.ts +10 -0
- package/lib/typescript/classes/HMSInteractivityEncoder.d.ts +3 -0
- package/lib/typescript/classes/HMSSDK.d.ts +7 -0
- package/lib/typescript/classes/polls/DecodedPollLeaderboardResponse.d.ts +37 -0
- package/lib/typescript/classes/polls/HMSPoll.d.ts +5 -13
- package/lib/typescript/classes/polls/HMSPollCreateParams.d.ts +1 -4
- package/lib/typescript/classes/polls/HMSPollLeaderboardEntry.d.ts +9 -0
- package/lib/typescript/classes/polls/HMSPollLeaderboardSummary.d.ts +7 -0
- package/lib/typescript/classes/polls/PollLeaderboardResponse.d.ts +7 -0
- package/lib/typescript/index.d.ts +3 -0
- package/package.json +1 -1
- package/sdk-versions.json +2 -2
- package/src/classes/HMSHLSTimedMetadata.ts +4 -0
- package/src/classes/HMSInteractivityCenter.ts +30 -0
- package/src/classes/HMSInteractivityEncoder.ts +57 -2
- package/src/classes/HMSSDK.tsx +14 -0
- package/src/classes/polls/DecodedPollLeaderboardResponse.ts +43 -0
- package/src/classes/polls/HMSPoll.ts +5 -14
- package/src/classes/polls/HMSPollCreateParams.ts +2 -3
- package/src/classes/polls/HMSPollLeaderboardEntry.ts +10 -0
- package/src/classes/polls/HMSPollLeaderboardSummary.ts +7 -0
- package/src/classes/polls/PollLeaderboardResponse.ts +8 -0
- package/src/components/HMSHLSPlayer/HMSHLSPlayer.tsx +3 -14
- package/src/index.ts +3 -0
|
@@ -6,8 +6,6 @@ import android.view.LayoutInflater
|
|
|
6
6
|
import android.widget.FrameLayout
|
|
7
7
|
import androidx.media3.common.Player
|
|
8
8
|
import androidx.media3.common.VideoSize
|
|
9
|
-
import androidx.media3.ui.AspectRatioFrameLayout.RESIZE_MODE_FIT
|
|
10
|
-
import androidx.media3.ui.AspectRatioFrameLayout.RESIZE_MODE_ZOOM
|
|
11
9
|
import androidx.media3.ui.PlayerView
|
|
12
10
|
import com.facebook.react.bridge.Arguments
|
|
13
11
|
import com.facebook.react.bridge.ReactContext
|
|
@@ -133,13 +131,6 @@ class HMSHLSPlayer(context: ReactContext) : FrameLayout(context) {
|
|
|
133
131
|
|
|
134
132
|
localPlayerView?.player?.addListener(
|
|
135
133
|
object : Player.Listener {
|
|
136
|
-
override fun onSurfaceSizeChanged(
|
|
137
|
-
width: Int,
|
|
138
|
-
height: Int,
|
|
139
|
-
) {
|
|
140
|
-
super.onSurfaceSizeChanged(width, height)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
134
|
override fun onVideoSizeChanged(videoSize: VideoSize) {
|
|
144
135
|
super.onVideoSizeChanged(videoSize)
|
|
145
136
|
|
|
@@ -147,12 +138,6 @@ class HMSHLSPlayer(context: ReactContext) : FrameLayout(context) {
|
|
|
147
138
|
val width = videoSize.width.toDouble()
|
|
148
139
|
val height = videoSize.height.toDouble()
|
|
149
140
|
|
|
150
|
-
if (width >= height) {
|
|
151
|
-
playerView?.resizeMode = RESIZE_MODE_FIT
|
|
152
|
-
} else {
|
|
153
|
-
playerView?.resizeMode = RESIZE_MODE_ZOOM
|
|
154
|
-
}
|
|
155
|
-
|
|
156
141
|
val data = Arguments.createMap()
|
|
157
142
|
data.putDouble("width", width)
|
|
158
143
|
data.putDouble("height", height)
|
|
@@ -530,6 +530,8 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
530
530
|
hms?.stopRtmpAndRecording(callback)
|
|
531
531
|
}
|
|
532
532
|
|
|
533
|
+
// region - HLS Streaming
|
|
534
|
+
|
|
533
535
|
@ReactMethod
|
|
534
536
|
fun startHLSStreaming(
|
|
535
537
|
data: ReadableMap,
|
|
@@ -550,6 +552,24 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
550
552
|
hms?.stopHLSStreaming(callback)
|
|
551
553
|
}
|
|
552
554
|
|
|
555
|
+
@ReactMethod
|
|
556
|
+
fun sendHLSTimedMetadata(
|
|
557
|
+
data: ReadableMap,
|
|
558
|
+
callback: Promise?,
|
|
559
|
+
) {
|
|
560
|
+
val rnSDK = HMSHelper.getHms(data, hmsCollection)
|
|
561
|
+
rnSDK?.let { sdk ->
|
|
562
|
+
sdk.sendHLSTimedMetadata(data, callback)
|
|
563
|
+
return
|
|
564
|
+
}
|
|
565
|
+
callback?.reject(
|
|
566
|
+
"6004",
|
|
567
|
+
"HMS SDK not initialized",
|
|
568
|
+
)
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// endregion
|
|
572
|
+
|
|
553
573
|
@ReactMethod
|
|
554
574
|
fun changeName(
|
|
555
575
|
data: ReadableMap,
|
|
@@ -1396,6 +1416,24 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
1396
1416
|
"HMS SDK not initialized",
|
|
1397
1417
|
)
|
|
1398
1418
|
}
|
|
1419
|
+
|
|
1420
|
+
@ReactMethod
|
|
1421
|
+
fun fetchLeaderboard(
|
|
1422
|
+
data: ReadableMap,
|
|
1423
|
+
promise: Promise?,
|
|
1424
|
+
) {
|
|
1425
|
+
val rnSDK = HMSHelper.getHms(data, hmsCollection)
|
|
1426
|
+
rnSDK?.let { sdk ->
|
|
1427
|
+
sdk.interactivityCenter?.let { center ->
|
|
1428
|
+
center.fetchLeaderboard(data, promise)
|
|
1429
|
+
return
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
promise?.reject(
|
|
1433
|
+
"6004",
|
|
1434
|
+
"HMS SDK not initialized",
|
|
1435
|
+
)
|
|
1436
|
+
}
|
|
1399
1437
|
// endregion
|
|
1400
1438
|
|
|
1401
1439
|
// region ActivityLifecycleCallbacks
|
|
@@ -1580,6 +1580,8 @@ class HMSRNSDK(
|
|
|
1580
1580
|
)
|
|
1581
1581
|
}
|
|
1582
1582
|
|
|
1583
|
+
// region - HLS Streaming
|
|
1584
|
+
|
|
1583
1585
|
fun startHLSStreaming(
|
|
1584
1586
|
data: ReadableMap,
|
|
1585
1587
|
callback: Promise?,
|
|
@@ -1614,6 +1616,42 @@ class HMSRNSDK(
|
|
|
1614
1616
|
)
|
|
1615
1617
|
}
|
|
1616
1618
|
|
|
1619
|
+
fun sendHLSTimedMetadata(
|
|
1620
|
+
data: ReadableMap,
|
|
1621
|
+
callback: Promise?,
|
|
1622
|
+
) {
|
|
1623
|
+
val metadataArrayList = data.getArray("metadata")?.toArrayList() as? ArrayList<HashMap<String, Any>>
|
|
1624
|
+
|
|
1625
|
+
if (metadataArrayList == null) {
|
|
1626
|
+
val errorMessage = "sendHLSTimedMetadata: INVALID_METADATA"
|
|
1627
|
+
rejectCallback(callback, errorMessage)
|
|
1628
|
+
return
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
val metadata =
|
|
1632
|
+
metadataArrayList.mapNotNull { map ->
|
|
1633
|
+
val payload = map["payload"] as? String
|
|
1634
|
+
val duration = map["duration"] as? Double
|
|
1635
|
+
|
|
1636
|
+
payload?.let { HMSHLSTimedMetadata(it, duration?.toLong() ?: 1) }
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
hmsSDK?.setHlsSessionMetadata(
|
|
1640
|
+
metadata,
|
|
1641
|
+
object : HMSActionResultListener {
|
|
1642
|
+
override fun onSuccess() {
|
|
1643
|
+
callback?.resolve(true)
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
override fun onError(error: HMSException) {
|
|
1647
|
+
callback?.reject(error.code.toString(), error.message)
|
|
1648
|
+
}
|
|
1649
|
+
},
|
|
1650
|
+
)
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
// endregion
|
|
1654
|
+
|
|
1617
1655
|
fun changeName(
|
|
1618
1656
|
data: ReadableMap,
|
|
1619
1657
|
callback: Promise?,
|
package/android/src/main/java/com/reactnativehmssdk/Interactivity/HMSInteractivityDecoder.kt
CHANGED
|
@@ -10,8 +10,12 @@ import live.hms.video.polls.models.answer.HMSPollQuestionAnswer
|
|
|
10
10
|
import live.hms.video.polls.models.answer.HmsPollAnswer
|
|
11
11
|
import live.hms.video.polls.models.answer.PollAnswerItem
|
|
12
12
|
import live.hms.video.polls.models.answer.PollAnswerResponse
|
|
13
|
+
import live.hms.video.polls.models.network.HMSPollResponsePeerInfo
|
|
13
14
|
import live.hms.video.polls.models.question.HMSPollQuestion
|
|
14
15
|
import live.hms.video.polls.models.question.HMSPollQuestionOption
|
|
16
|
+
import live.hms.video.polls.network.HMSPollLeaderboardEntry
|
|
17
|
+
import live.hms.video.polls.network.HMSPollLeaderboardSummary
|
|
18
|
+
import live.hms.video.polls.network.PollLeaderboardResponse
|
|
15
19
|
import live.hms.video.polls.network.PollResultsDisplay
|
|
16
20
|
|
|
17
21
|
object HMSInteractivityDecoder {
|
|
@@ -310,6 +314,87 @@ object HMSInteractivityDecoder {
|
|
|
310
314
|
return results
|
|
311
315
|
}
|
|
312
316
|
|
|
317
|
+
fun getPollLeaderboardResponse(pollLeaderboardResponse: PollLeaderboardResponse): WritableMap {
|
|
318
|
+
val results = Arguments.createMap()
|
|
319
|
+
|
|
320
|
+
pollLeaderboardResponse.hasNext?.let {
|
|
321
|
+
results.putBoolean("hasNext", it)
|
|
322
|
+
}
|
|
323
|
+
pollLeaderboardResponse.summary?.let {
|
|
324
|
+
results.putMap("summary", getHMSPollLeaderboardSummary(it))
|
|
325
|
+
}
|
|
326
|
+
pollLeaderboardResponse.entries?.let {
|
|
327
|
+
results.putArray("entries", getHMSPollLeaderboardEntries(it))
|
|
328
|
+
}
|
|
329
|
+
return results
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
private fun getHMSPollLeaderboardSummary(pollLeaderboardSummary: HMSPollLeaderboardSummary): WritableMap {
|
|
333
|
+
val summary = Arguments.createMap()
|
|
334
|
+
pollLeaderboardSummary.averageScore?.let {
|
|
335
|
+
summary.putDouble("averageScore", it.toDouble())
|
|
336
|
+
}
|
|
337
|
+
pollLeaderboardSummary.averageTime?.let {
|
|
338
|
+
summary.putString("averageTime", it.toString())
|
|
339
|
+
}
|
|
340
|
+
pollLeaderboardSummary.totalPeersCount?.let {
|
|
341
|
+
summary.putInt("totalPeersCount", it)
|
|
342
|
+
}
|
|
343
|
+
pollLeaderboardSummary.respondedCorrectlyPeersCount?.let {
|
|
344
|
+
summary.putInt("respondedCorrectlyPeersCount", it)
|
|
345
|
+
}
|
|
346
|
+
pollLeaderboardSummary.respondedPeersCount?.let {
|
|
347
|
+
summary.putInt("respondedPeersCount", it)
|
|
348
|
+
}
|
|
349
|
+
return summary
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
private fun getHMSPollLeaderboardEntries(pollLeaderboardEntries: List<HMSPollLeaderboardEntry>): WritableArray {
|
|
353
|
+
val list = Arguments.createArray()
|
|
354
|
+
pollLeaderboardEntries.forEach {
|
|
355
|
+
list.pushMap(getHMSPollLeaderboardEntry(it))
|
|
356
|
+
}
|
|
357
|
+
return list
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
private fun getHMSPollLeaderboardEntry(pollLeaderboardEntry: HMSPollLeaderboardEntry): WritableMap {
|
|
361
|
+
val entry = Arguments.createMap()
|
|
362
|
+
pollLeaderboardEntry.duration?.let {
|
|
363
|
+
entry.putString("duration", it.toString())
|
|
364
|
+
}
|
|
365
|
+
pollLeaderboardEntry.peer?.let {
|
|
366
|
+
entry.putMap("peer", getHMSPollResponsePeerInfo(it))
|
|
367
|
+
}
|
|
368
|
+
pollLeaderboardEntry.totalResponses?.let {
|
|
369
|
+
entry.putString("totalResponses", it.toString())
|
|
370
|
+
}
|
|
371
|
+
pollLeaderboardEntry.correctResponses?.let {
|
|
372
|
+
entry.putString("correctResponses", it.toString())
|
|
373
|
+
}
|
|
374
|
+
pollLeaderboardEntry.position?.let {
|
|
375
|
+
entry.putString("position", it.toString())
|
|
376
|
+
}
|
|
377
|
+
pollLeaderboardEntry.score?.let {
|
|
378
|
+
entry.putString("score", it.toString())
|
|
379
|
+
}
|
|
380
|
+
return entry
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
private fun getHMSPollResponsePeerInfo(pollResponsePeerInfo: HMSPollResponsePeerInfo): WritableMap {
|
|
384
|
+
val peerInfo = Arguments.createMap()
|
|
385
|
+
peerInfo.putString("userHash", pollResponsePeerInfo.hash)
|
|
386
|
+
pollResponsePeerInfo.peerid?.let {
|
|
387
|
+
peerInfo.putString("peerId", it)
|
|
388
|
+
}
|
|
389
|
+
pollResponsePeerInfo.userid?.let {
|
|
390
|
+
peerInfo.putString("customerUserId", it)
|
|
391
|
+
}
|
|
392
|
+
pollResponsePeerInfo.username?.let {
|
|
393
|
+
peerInfo.putString("userName", it)
|
|
394
|
+
}
|
|
395
|
+
return peerInfo
|
|
396
|
+
}
|
|
397
|
+
|
|
313
398
|
private fun getHMSPollQuestionResponseResult(hmsPollQuestionResponseResult: PollAnswerItem): WritableMap {
|
|
314
399
|
val result = Arguments.createMap()
|
|
315
400
|
|
package/android/src/main/java/com/reactnativehmssdk/Interactivity/HMSRNInteractivityCenter.kt
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
package com.reactnativehmssdk
|
|
2
|
-
import android.util.Log
|
|
3
2
|
import com.facebook.react.bridge.Arguments
|
|
4
3
|
import com.facebook.react.bridge.Promise
|
|
5
4
|
import com.facebook.react.bridge.ReadableMap
|
|
@@ -10,6 +9,7 @@ import live.hms.video.interactivity.HmsPollUpdateListener
|
|
|
10
9
|
import live.hms.video.polls.models.HMSPollUpdateType
|
|
11
10
|
import live.hms.video.polls.models.HmsPoll
|
|
12
11
|
import live.hms.video.polls.models.answer.PollAnswerResponse
|
|
12
|
+
import live.hms.video.polls.network.PollLeaderboardResponse
|
|
13
13
|
import live.hms.video.sdk.HMSActionResultListener
|
|
14
14
|
import live.hms.video.sdk.HMSSDK
|
|
15
15
|
import live.hms.video.sdk.HmsTypedActionResultListener
|
|
@@ -37,8 +37,6 @@ class HMSRNInteractivityCenter(private val sdk: HMSSDK, private val rnSDK: HMSRN
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
// region Create Polls
|
|
41
|
-
|
|
42
40
|
fun quickStartPoll(
|
|
43
41
|
data: ReadableMap,
|
|
44
42
|
promise: Promise?,
|
|
@@ -59,64 +57,29 @@ class HMSRNInteractivityCenter(private val sdk: HMSSDK, private val rnSDK: HMSRN
|
|
|
59
57
|
)
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
/*
|
|
63
|
-
|
|
64
|
-
func add(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
|
|
65
|
-
guard let pollId = data["pollId"] as? String,
|
|
66
|
-
let poll = self.hmssdk?.interactivityCenter.polls.first(where: {poll in poll.pollID == pollId}) else {
|
|
67
|
-
reject?("6004", "Unable to find HMSPoll with given pollId", nil)
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
guard let pollQuestionIndex = data["pollQuestionIndex"] as? Int,
|
|
71
|
-
let pollQuestion = poll.questions?.first(where: {question in question.index == pollQuestionIndex}) else {
|
|
72
|
-
reject?("6004", "Unable to find HMSPollQuestion in poll with given question index", nil)
|
|
73
|
-
return
|
|
74
|
-
}
|
|
75
|
-
guard let responses = data["responses"] as? NSDictionary else {
|
|
76
|
-
reject?("6004", "responses field is required", nil)
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
let pollResponseBuilder = HMSInteractivityHelper.getPollResponseBuilder(responses, poll: poll, pollQuestion: pollQuestion)
|
|
81
|
-
|
|
82
|
-
self.hmssdk?.interactivityCenter.add(response: pollResponseBuilder) { pollQuestionResponseResult, error in
|
|
83
|
-
if let nonnilError = error {
|
|
84
|
-
reject?("6004", nonnilError.localizedDescription, nil)
|
|
85
|
-
return
|
|
86
|
-
}
|
|
87
|
-
if let pollQuestionResponseResult = pollQuestionResponseResult {
|
|
88
|
-
resolve?(HMSInteractivityDecoder.getHMSPollQuestionResponseResults(pollQuestionResponseResult))
|
|
89
|
-
} else {
|
|
90
|
-
resolve?(nil)
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
60
|
fun addResponseOnPollQuestion(
|
|
98
61
|
data: ReadableMap,
|
|
99
62
|
promise: Promise?,
|
|
100
63
|
) {
|
|
101
64
|
val pollId = data.getString("pollId")
|
|
102
65
|
if (pollId == null) {
|
|
103
|
-
promise?.reject("
|
|
66
|
+
promise?.reject("6004", "pollId is required")
|
|
104
67
|
return
|
|
105
68
|
}
|
|
106
69
|
val poll = this.sdk.getHmsInteractivityCenter().polls.find { it.pollId == pollId }
|
|
107
70
|
if (poll == null) {
|
|
108
|
-
promise?.reject("
|
|
71
|
+
promise?.reject("6004", "No HMSPoll with pollId `$pollId`")
|
|
109
72
|
return
|
|
110
73
|
}
|
|
111
74
|
val pollQuestionIndex = data.getInt("pollQuestionIndex")
|
|
112
75
|
val pollQuestion = poll.questions?.find { it.questionID == pollQuestionIndex }
|
|
113
76
|
if (pollQuestion == null) {
|
|
114
|
-
promise?.reject("
|
|
77
|
+
promise?.reject("6004", "No HMSPollQuestion in poll with given question index")
|
|
115
78
|
return
|
|
116
79
|
}
|
|
117
80
|
val responses = data.getMap("responses")
|
|
118
81
|
if (responses == null) {
|
|
119
|
-
promise?.reject("
|
|
82
|
+
promise?.reject("6004", "responses field is required")
|
|
120
83
|
return
|
|
121
84
|
}
|
|
122
85
|
val pollResponseBuilder = HMSInteractivityHelper.getPollResponseBuilder(responses, poll, pollQuestion)
|
|
@@ -140,12 +103,12 @@ class HMSRNInteractivityCenter(private val sdk: HMSSDK, private val rnSDK: HMSRN
|
|
|
140
103
|
) {
|
|
141
104
|
val pollId = data.getString("pollId")
|
|
142
105
|
if (pollId == null) {
|
|
143
|
-
promise?.reject("
|
|
106
|
+
promise?.reject("6004", "pollId is required")
|
|
144
107
|
return
|
|
145
108
|
}
|
|
146
109
|
val poll = this.sdk.getHmsInteractivityCenter().polls.find { it.pollId == pollId }
|
|
147
110
|
if (poll == null) {
|
|
148
|
-
promise?.reject("
|
|
111
|
+
promise?.reject("6004", "No HMSPoll with pollId `$pollId`")
|
|
149
112
|
return
|
|
150
113
|
}
|
|
151
114
|
this.sdk.getHmsInteractivityCenter().stop(
|
|
@@ -162,23 +125,38 @@ class HMSRNInteractivityCenter(private val sdk: HMSSDK, private val rnSDK: HMSRN
|
|
|
162
125
|
)
|
|
163
126
|
}
|
|
164
127
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
128
|
+
fun fetchLeaderboard(
|
|
129
|
+
data: ReadableMap,
|
|
130
|
+
promise: Promise?,
|
|
131
|
+
) {
|
|
132
|
+
val pollId = data.getString("pollId")
|
|
133
|
+
if (pollId == null) {
|
|
134
|
+
promise?.reject("6004", "pollId is required")
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
val poll = this.sdk.getHmsInteractivityCenter().polls.find { it.pollId == pollId }
|
|
138
|
+
if (poll == null) {
|
|
139
|
+
promise?.reject("6004", "No HMSPoll with pollId `$pollId`")
|
|
140
|
+
return
|
|
141
|
+
}
|
|
142
|
+
val count = data.getInt("count")
|
|
143
|
+
val startIndex = data.getInt("startIndex")
|
|
144
|
+
val includeCurrentPeer = data.getBoolean("includeCurrentPeer")
|
|
145
|
+
|
|
146
|
+
this.sdk.getHmsInteractivityCenter().fetchLeaderboard(
|
|
147
|
+
pollId = poll.pollId,
|
|
148
|
+
count = count.toLong(),
|
|
149
|
+
startIndex = startIndex.toLong(),
|
|
150
|
+
includeCurrentPeer = includeCurrentPeer,
|
|
151
|
+
object : HmsTypedActionResultListener<PollLeaderboardResponse> {
|
|
152
|
+
override fun onSuccess(result: PollLeaderboardResponse) {
|
|
153
|
+
promise?.resolve(HMSInteractivityDecoder.getPollLeaderboardResponse(result))
|
|
154
|
+
}
|
|
178
155
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
156
|
+
override fun onError(error: HMSException) {
|
|
157
|
+
promise?.reject(error.code.toString(), error.description)
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
)
|
|
182
161
|
}
|
|
183
|
-
// endregion
|
|
184
162
|
}
|
|
@@ -220,4 +220,54 @@ class HMSInteractivityDecoder {
|
|
|
220
220
|
}
|
|
221
221
|
return result
|
|
222
222
|
}
|
|
223
|
+
|
|
224
|
+
static func getLeaderboardResponse(_ response: HMSPollLeaderboardResponse) -> [String: AnyHashable] {
|
|
225
|
+
var result = [String: AnyHashable]()
|
|
226
|
+
|
|
227
|
+
result["hasNext"] = response.hasNext
|
|
228
|
+
|
|
229
|
+
result["summary"] = getLeaderboardSummary(response.summary)
|
|
230
|
+
|
|
231
|
+
result["entries"] = getLeaderboardEntries(response.entries)
|
|
232
|
+
|
|
233
|
+
return result
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
static func getLeaderboardSummary(_ summary: HMSPollLeaderboardSummary) -> [String: AnyHashable] {
|
|
237
|
+
var result = [String: AnyHashable]()
|
|
238
|
+
|
|
239
|
+
result["averageScore"] = summary.averageScore
|
|
240
|
+
result["averageTime"] = summary.averageTime
|
|
241
|
+
result["totalPeersCount"] = summary.totalPeersCount
|
|
242
|
+
result["respondedCorrectlyPeersCount"] = summary.respondedCorrectlyPeersCount
|
|
243
|
+
result["respondedPeersCount"] = summary.respondedPeersCount
|
|
244
|
+
|
|
245
|
+
return result
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
static func getLeaderboardEntries(_ entries: [HMSPollLeaderboardEntry]) -> [[String: AnyHashable]] {
|
|
249
|
+
var result = [[String: AnyHashable]]()
|
|
250
|
+
|
|
251
|
+
for entry in entries {
|
|
252
|
+
result.append(getLeaderboardEntry(entry))
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return result
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
static func getLeaderboardEntry(_ entry: HMSPollLeaderboardEntry) -> [String: AnyHashable] {
|
|
259
|
+
var result = [String: AnyHashable]()
|
|
260
|
+
|
|
261
|
+
result["duration"] = entry.duration
|
|
262
|
+
result["totalResponses"] = entry.totalResponses
|
|
263
|
+
result["correctResponses"] = entry.correctResponses
|
|
264
|
+
result["position"] = entry.position
|
|
265
|
+
result["score"] = entry.score
|
|
266
|
+
|
|
267
|
+
if let peer = entry.peer {
|
|
268
|
+
result["peer"] = getHMSPollResponsePeerInfo(peer)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return result
|
|
272
|
+
}
|
|
223
273
|
}
|
package/ios/HMSManager.m
CHANGED
|
@@ -107,6 +107,10 @@ RCT_EXTERN_METHOD(stopHLSStreaming
|
|
|
107
107
|
: (NSDictionary)data
|
|
108
108
|
: (RCTPromiseResolveBlock)resolve
|
|
109
109
|
: (RCTPromiseRejectBlock)reject)
|
|
110
|
+
RCT_EXTERN_METHOD(sendHLSTimedMetadata
|
|
111
|
+
: (NSDictionary)data
|
|
112
|
+
: (RCTPromiseResolveBlock)resolve
|
|
113
|
+
: (RCTPromiseRejectBlock)reject)
|
|
110
114
|
RCT_EXTERN_METHOD(changeName
|
|
111
115
|
: (NSDictionary)data
|
|
112
116
|
: (RCTPromiseResolveBlock)resolve
|
|
@@ -313,4 +317,9 @@ RCT_EXTERN_METHOD(stopPoll
|
|
|
313
317
|
: (RCTPromiseResolveBlock)resolve
|
|
314
318
|
: (RCTPromiseRejectBlock)reject)
|
|
315
319
|
|
|
320
|
+
RCT_EXTERN_METHOD(fetchLeaderboard
|
|
321
|
+
: (NSDictionary)data
|
|
322
|
+
: (RCTPromiseResolveBlock)resolve
|
|
323
|
+
: (RCTPromiseRejectBlock)reject)
|
|
324
|
+
|
|
316
325
|
@end
|
package/ios/HMSManager.swift
CHANGED
|
@@ -349,7 +349,7 @@ class HMSManager: RCTEventEmitter {
|
|
|
349
349
|
hms?.stopRtmpAndRecording(resolve, reject)
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
-
// MARK: - HLS Streaming
|
|
352
|
+
// MARK: - HLS Streaming
|
|
353
353
|
|
|
354
354
|
@objc
|
|
355
355
|
func startHLSStreaming(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
|
|
@@ -365,6 +365,15 @@ class HMSManager: RCTEventEmitter {
|
|
|
365
365
|
hms?.stopHLSStreaming(resolve, reject)
|
|
366
366
|
}
|
|
367
367
|
|
|
368
|
+
@objc
|
|
369
|
+
func sendHLSTimedMetadata(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
|
|
370
|
+
guard let rnsdk = HMSHelper.getHms(data, hmsCollection) else {
|
|
371
|
+
reject?("6004", "HMSRNSDK instance not found!", nil)
|
|
372
|
+
return
|
|
373
|
+
}
|
|
374
|
+
rnsdk.sendHLSTimedMetadata(data, resolve, reject)
|
|
375
|
+
}
|
|
376
|
+
|
|
368
377
|
// MARK: - Screen Share
|
|
369
378
|
|
|
370
379
|
@objc
|
|
@@ -672,4 +681,13 @@ class HMSManager: RCTEventEmitter {
|
|
|
672
681
|
}
|
|
673
682
|
interactivity.stop(data, resolve, reject)
|
|
674
683
|
}
|
|
684
|
+
|
|
685
|
+
@objc
|
|
686
|
+
func fetchLeaderboard(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
|
|
687
|
+
guard let rnsdk = HMSHelper.getHms(data, hmsCollection), let interactivity = rnsdk.interactivity else {
|
|
688
|
+
reject?("6004", "HMSRNSDK instance not found!", nil)
|
|
689
|
+
return
|
|
690
|
+
}
|
|
691
|
+
interactivity.fetchLeaderboard(data, resolve, reject)
|
|
692
|
+
}
|
|
675
693
|
}
|
|
@@ -86,4 +86,35 @@ class HMSRNInteractivityCenter {
|
|
|
86
86
|
resolve?(success)
|
|
87
87
|
})
|
|
88
88
|
}
|
|
89
|
+
|
|
90
|
+
func fetchLeaderboard(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
|
|
91
|
+
guard let pollId = data["pollId"] as? String,
|
|
92
|
+
let poll = self.hmssdk?.interactivityCenter.polls.first(where: {poll in poll.pollID == pollId}) else {
|
|
93
|
+
reject?("6004", "Unable to find HMSPoll with given pollId", nil)
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
guard let count = data["count"] as? Int,
|
|
98
|
+
let startIndex = data["startIndex"] as? Int
|
|
99
|
+
else {
|
|
100
|
+
reject?("6004", "Unable to find required parameters", nil)
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let includeCurrentPeer = data["includeCurrentPeer"] as? Bool ?? false
|
|
105
|
+
|
|
106
|
+
self.hmssdk?.interactivityCenter.fetchLeaderboard(for: poll, offset: startIndex, count: count, includeCurrentPeer: includeCurrentPeer) { response, error in
|
|
107
|
+
|
|
108
|
+
if let nonnilError = error {
|
|
109
|
+
reject?("6004", nonnilError.localizedDescription, nil)
|
|
110
|
+
return
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if let response = response {
|
|
114
|
+
resolve?(HMSInteractivityDecoder.getLeaderboardResponse(response))
|
|
115
|
+
} else {
|
|
116
|
+
reject?("6004", "Could not fetch leaderboard response", nil)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
89
120
|
}
|
package/ios/HMSRNSDK.swift
CHANGED
|
@@ -797,6 +797,8 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
797
797
|
})
|
|
798
798
|
}
|
|
799
799
|
|
|
800
|
+
// MARK: - HLS Streaming
|
|
801
|
+
|
|
800
802
|
func startHLSStreaming(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
|
|
801
803
|
let recordConfig = HMSHelper.getHlsRecordingConfig(data.value(forKey: "hlsRecordingConfig") as? NSDictionary)
|
|
802
804
|
let hlsMeetingUrlVariant = HMSHelper.getHMSHLSMeetingURLVariants(data.value(forKey: "meetingURLVariants") as? [[String: Any]])
|
|
@@ -828,6 +830,38 @@ class HMSRNSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
828
830
|
})
|
|
829
831
|
}
|
|
830
832
|
|
|
833
|
+
func sendHLSTimedMetadata(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
|
|
834
|
+
guard let metadataArrayList = data["metadata"] as? [NSDictionary] else {
|
|
835
|
+
let errorMessage = "\(#function) metadata for sendHLSTimedMetadata was not found"
|
|
836
|
+
reject?("6004", errorMessage, nil)
|
|
837
|
+
return
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
let metadata = metadataArrayList.compactMap { (dict: NSDictionary) -> HMSHLSTimedMetadata? in
|
|
841
|
+
guard let payload = dict["payload"] as? String else {
|
|
842
|
+
return nil
|
|
843
|
+
}
|
|
844
|
+
if let duration = dict["duration"] as? Int {
|
|
845
|
+
return HMSHLSTimedMetadata(payload: payload, duration: duration)
|
|
846
|
+
} else {
|
|
847
|
+
return HMSHLSTimedMetadata(payload: payload)
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
DispatchQueue.main.async { [weak self] in
|
|
852
|
+
self?.hms?.sendHLSTimedMetadata(metadata) { success, error in
|
|
853
|
+
if let error = error as? HMSError {
|
|
854
|
+
print(#function, "Unable to send metadata: \(error)")
|
|
855
|
+
reject?("6004", error.localizedDescription, nil)
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
resolve?(success)
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
// MARK: -
|
|
864
|
+
|
|
831
865
|
func changeName(_ data: NSDictionary, _ resolve: RCTPromiseResolveBlock?, _ reject: RCTPromiseRejectBlock?) {
|
|
832
866
|
guard let name = data.value(forKey: "name") as? String
|
|
833
867
|
else {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["HMSHLSTimedMetadata.ts"],"sourcesContent":["export interface HMSHLSTimedMetadata {\n payload: string;\n duration: number;\n}\n"],"mappings":""}
|
|
@@ -94,6 +94,27 @@ class HMSInteractivityCenter {
|
|
|
94
94
|
_HMSLogger.logger === null || _HMSLogger.logger === void 0 || _HMSLogger.logger.verbose('#Function stop', JSON.stringify(data));
|
|
95
95
|
return _HMSManagerModule.default.stopPoll(data);
|
|
96
96
|
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Fetches the leaderboard for a poll
|
|
100
|
+
* @param pollId - The id of the poll
|
|
101
|
+
* @param count - The number of entries to fetch
|
|
102
|
+
* @param startIndex - The index to start fetching from
|
|
103
|
+
* @param includeCurrentPeer - Whether to include the current peer in the fetched leaderboard entries
|
|
104
|
+
* @returns Promise<PollLeaderboardResponse>
|
|
105
|
+
*/
|
|
106
|
+
async fetchLeaderboard(pollId, count, startIndex, includeCurrentPeer) {
|
|
107
|
+
const data = {
|
|
108
|
+
id: _HMSConstants.HMSConstants.DEFAULT_SDK_ID,
|
|
109
|
+
pollId,
|
|
110
|
+
count,
|
|
111
|
+
startIndex,
|
|
112
|
+
includeCurrentPeer
|
|
113
|
+
};
|
|
114
|
+
_HMSLogger.logger === null || _HMSLogger.logger === void 0 || _HMSLogger.logger.verbose('#Function fetchLeaderboard', data);
|
|
115
|
+
const response = await _HMSManagerModule.default.fetchLeaderboard(data);
|
|
116
|
+
return _HMSInteractivityEncoder.HMSInteractivityEncoder.transformPollLeaderboardResponse(response);
|
|
117
|
+
}
|
|
97
118
|
}
|
|
98
119
|
exports.HMSInteractivityCenter = HMSInteractivityCenter;
|
|
99
120
|
//# sourceMappingURL=HMSInteractivityCenter.js.map
|