@capgo/capacitor-stream-call 0.0.18 → 0.0.19
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.
|
@@ -29,7 +29,6 @@ import io.getstream.video.android.core.StreamVideo
|
|
|
29
29
|
import io.getstream.video.android.core.StreamVideoBuilder
|
|
30
30
|
import io.getstream.video.android.core.notifications.NotificationConfig
|
|
31
31
|
import io.getstream.video.android.core.notifications.NotificationHandler
|
|
32
|
-
import io.getstream.video.android.core.sounds.emptyRingingConfig
|
|
33
32
|
import io.getstream.video.android.core.sounds.toSounds
|
|
34
33
|
import io.getstream.video.android.model.StreamCallId
|
|
35
34
|
import io.getstream.video.android.model.User
|
|
@@ -46,6 +45,7 @@ import io.getstream.android.video.generated.models.CallCreatedEvent
|
|
|
46
45
|
import io.getstream.android.video.generated.models.CallEndedEvent
|
|
47
46
|
import io.getstream.android.video.generated.models.CallMissedEvent
|
|
48
47
|
import io.getstream.android.video.generated.models.CallRejectedEvent
|
|
48
|
+
import io.getstream.android.video.generated.models.CallRingEvent
|
|
49
49
|
import io.getstream.android.video.generated.models.CallSessionEndedEvent
|
|
50
50
|
import io.getstream.android.video.generated.models.CallSessionStartedEvent
|
|
51
51
|
import io.getstream.android.video.generated.models.VideoEvent
|
|
@@ -185,7 +185,7 @@ public class StreamCallPlugin : Plugin() {
|
|
|
185
185
|
declineCall(declinedCall)
|
|
186
186
|
},
|
|
187
187
|
onAcceptCall = { acceptedCall ->
|
|
188
|
-
|
|
188
|
+
internalAcceptCall(acceptedCall)
|
|
189
189
|
},
|
|
190
190
|
onHideIncomingCall = {
|
|
191
191
|
hideIncomingCall()
|
|
@@ -207,7 +207,7 @@ public class StreamCallPlugin : Plugin() {
|
|
|
207
207
|
val call = streamVideoClient?.call(id = cid.id, type = cid.type)
|
|
208
208
|
kotlinx.coroutines.GlobalScope.launch {
|
|
209
209
|
call?.get()
|
|
210
|
-
call?.let {
|
|
210
|
+
call?.let { internalAcceptCall(it) }
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
}
|
|
@@ -565,6 +565,9 @@ public class StreamCallPlugin : Plugin() {
|
|
|
565
565
|
client.subscribe { event: VideoEvent ->
|
|
566
566
|
android.util.Log.v("StreamCallPlugin", "Received an event ${event.getEventType()} $event")
|
|
567
567
|
when (event) {
|
|
568
|
+
is CallRingEvent -> {
|
|
569
|
+
updateCallStatusAndNotify(event.callCid, "ringing")
|
|
570
|
+
}
|
|
568
571
|
// Handle CallCreatedEvent differently - only log it but don't try to access members yet
|
|
569
572
|
is CallCreatedEvent -> {
|
|
570
573
|
val callCid = event.callCid
|
|
@@ -744,8 +747,42 @@ public class StreamCallPlugin : Plugin() {
|
|
|
744
747
|
})
|
|
745
748
|
}
|
|
746
749
|
|
|
750
|
+
@PluginMethod
|
|
751
|
+
public fun acceptCall(call: PluginCall) {
|
|
752
|
+
try {
|
|
753
|
+
val streamVideoCall = streamVideoClient?.state?.ringingCall?.value
|
|
754
|
+
if (streamVideoCall == null) {
|
|
755
|
+
call.reject("Ringing call is null")
|
|
756
|
+
return
|
|
757
|
+
}
|
|
758
|
+
kotlinx.coroutines.GlobalScope.launch {
|
|
759
|
+
internalAcceptCall(streamVideoCall)
|
|
760
|
+
}
|
|
761
|
+
} catch (t: Throwable) {
|
|
762
|
+
android.util.Log.d("StreamCallPlugin", "JS -> acceptCall fail", t);
|
|
763
|
+
call.reject("Cannot acceptCall")
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
@PluginMethod
|
|
768
|
+
public fun rejectCall(call: PluginCall) {
|
|
769
|
+
try {
|
|
770
|
+
val streamVideoCall = streamVideoClient?.state?.ringingCall?.value
|
|
771
|
+
if (streamVideoCall == null) {
|
|
772
|
+
call.reject("Ringing call is null")
|
|
773
|
+
return
|
|
774
|
+
}
|
|
775
|
+
kotlinx.coroutines.GlobalScope.launch {
|
|
776
|
+
declineCall(streamVideoCall)
|
|
777
|
+
}
|
|
778
|
+
} catch (t: Throwable) {
|
|
779
|
+
android.util.Log.d("StreamCallPlugin", "JS -> rejectCall fail", t);
|
|
780
|
+
call.reject("Cannot rejectCall")
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
747
784
|
@OptIn(DelicateCoroutinesApi::class)
|
|
748
|
-
private fun
|
|
785
|
+
private fun internalAcceptCall(call: Call) {
|
|
749
786
|
kotlinx.coroutines.GlobalScope.launch {
|
|
750
787
|
try {
|
|
751
788
|
// Stop ringtone
|
|
@@ -279,13 +279,26 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
279
279
|
let callId = callIdSplit[1]
|
|
280
280
|
|
|
281
281
|
let call = streamVideo.call(callType: String(callType), callId: String(callId))
|
|
282
|
-
|
|
282
|
+
guard let participantsCount = await MainActor.run(body: {
|
|
283
|
+
if call.id == streamVideo.state.activeCall?.id {
|
|
284
|
+
return (call.state.session?.participants.count) ?? streamVideo.state.activeCall?.state.participants.count
|
|
285
|
+
} else {
|
|
286
|
+
return (call.state.session?.participants.count)
|
|
287
|
+
}
|
|
288
|
+
}) else {
|
|
289
|
+
print("CallSessionParticipantLeftEvent no participantsCount")
|
|
290
|
+
continue
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if participantsCount - 1 <= 1 {
|
|
283
294
|
|
|
284
|
-
print("We are left solo in a call. Ending. cID: \(participantLeftEvent.callCid)")
|
|
295
|
+
print("We are left solo in a call. Ending. cID: \(participantLeftEvent.callCid). participantsCount: \(participantsCount)")
|
|
285
296
|
|
|
286
297
|
Task {
|
|
287
298
|
if let activeCall = streamVideo.state.activeCall {
|
|
288
299
|
activeCall.leave()
|
|
300
|
+
} else {
|
|
301
|
+
print("Active call isn't the one?")
|
|
289
302
|
}
|
|
290
303
|
}
|
|
291
304
|
}
|
|
@@ -784,6 +797,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
784
797
|
print("Accepting and joining call \(streamCall!.cId)...")
|
|
785
798
|
try await streamCall?.accept()
|
|
786
799
|
try await streamCall?.join(create: false)
|
|
800
|
+
try await streamCall?.get()
|
|
787
801
|
print("Successfully joined call")
|
|
788
802
|
|
|
789
803
|
// Update the CallOverlayView with the active call
|
package/package.json
CHANGED