Cleanup listener

This commit is contained in:
Benoit Marty 2020-05-28 12:39:04 +02:00 committed by Valere
parent dcae051e85
commit 8c9ca1e0f2
4 changed files with 15 additions and 14 deletions

View File

@ -41,7 +41,7 @@ interface CallsListener {
// */
// fun onCallHangUp(peerSignalingClient: PeerSignalingClient)
fun onCallInviteReceived(signalingRoomId: String, participantUserId: String, callInviteContent: CallInviteContent)
fun onCallInviteReceived(signalingRoomId: String, fromUserId: String, callInviteContent: CallInviteContent)
fun onCallAnswerReceived(callAnswerContent: CallAnswerContent)

View File

@ -48,7 +48,7 @@ internal class DefaultCallService @Inject constructor(
private val roomEventSender: RoomEventSender
) : CallService {
private val callListeners = ArrayList<CallsListener>()
private val callListeners = mutableSetOf<CallsListener>()
override fun getTurnServer(callback: MatrixCallback<TurnServer?>) {
TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
@ -126,7 +126,7 @@ internal class DefaultCallService @Inject constructor(
}
override fun addCallListener(listener: CallsListener) {
if (!callListeners.contains(listener)) callListeners.add(listener)
callListeners.add(listener)
}
override fun removeCallListener(listener: CallsListener) {
@ -154,7 +154,7 @@ internal class DefaultCallService @Inject constructor(
}
private fun onCallHangup(hangup: CallHangupContent) {
callListeners.forEach {
callListeners.toList().forEach {
tryThis {
it.onCallHangupReceived(hangup)
}
@ -162,19 +162,20 @@ internal class DefaultCallService @Inject constructor(
}
private fun onCallAnswer(answer: CallAnswerContent) {
callListeners.forEach {
callListeners.toList().forEach {
tryThis {
it.onCallAnswerReceived(answer)
}
}
}
private fun onCallInvite(roomId: String, userId: String, answer: CallInviteContent) {
if (userId == this.userId) return
private fun onCallInvite(roomId: String, fromUserId: String, invite: CallInviteContent) {
// Ignore the invitation from current user
if (fromUserId == userId) return
callListeners.forEach {
callListeners.toList().forEach {
tryThis {
it.onCallInviteReceived(roomId, userId, answer)
it.onCallInviteReceived(roomId, fromUserId, invite)
}
}
}

View File

@ -62,7 +62,7 @@ class VectorCallViewModel @AssistedInject constructor(
}
}
override fun onCallInviteReceived(signalingRoomId: String, participantUserId: String, callInviteContent: CallInviteContent) {
override fun onCallInviteReceived(signalingRoomId: String, fromUserId: String, callInviteContent: CallInviteContent) {
}
override fun onCallHangupReceived(callHangupContent: CallHangupContent) {

View File

@ -428,14 +428,14 @@ class WebRtcPeerConnectionManager @Inject constructor(
sendSdpOffer()
}
override fun onCallInviteReceived(signalingRoomId: String, participantUserId: String, callInviteContent: CallInviteContent) {
override fun onCallInviteReceived(signalingRoomId: String, fromUserId: String, callInviteContent: CallInviteContent) {
this.callId = callInviteContent.callId
this.signalingRoomId = signalingRoomId
this.participantUserId = participantUserId
this.participantUserId = fromUserId
this.isVideoCall = callInviteContent.isVideo()
startHeadsUpService(signalingRoomId, participantUserId, true, callInviteContent.isVideo())
context.startActivity(VectorCallActivity.newIntent(context, signalingRoomId, participantUserId, false, callInviteContent.isVideo()))
startHeadsUpService(signalingRoomId, fromUserId, true, callInviteContent.isVideo())
context.startActivity(VectorCallActivity.newIntent(context, signalingRoomId, fromUserId, false, callInviteContent.isVideo()))
startCall()
}