ConnectyCube / android-messenger-app

Chat and voice / video calling app using ConnectyCube
https://connectycube.com
Apache License 2.0
51 stars 23 forks source link

Users call each other at the same time and each one created different session at the same time! #45

Closed mwaked closed 4 years ago

mwaked commented 4 years ago

Users call each other at the same time and each one created different session at the same time!, and each one receive new session then their call close, What i can do in this case?, I want to direct connect together without closing the call if they call each other at the same time

override fun onReceiveNewSession(session: RTCSession) { Timber.d("onReceiveNewSession") if (currentSession != null) { Timber.d("reject new session, device is busy") session.rejectCall(null) } }

TatankaConCube commented 4 years ago

In current realisation it is expected behaviour, we manage one session at the same time. But ConnectyCube SDK provides possibility to work with few sessions at the same time. For example you can automatically reject new session only in case if current session’s state is BaseSession.RTCSessionState.RTC_SESSION_CONNECTED, but in this case you should manage call screens for few calls at the same time (outgoing and new incoming). To listen changes of session state you can use:

currentCall.addSessionCallbacksListener(object : RTCSessionStateCallback<RTCSession>{
    override fun onDisconnectedFromUser(rtcSession: RTCSession, userId: Int) {}

    override fun onConnectedToUser(rtcSession: RTCSession, userId: Int) {}

    override fun onConnectionClosedForUser(rtcSession: RTCSession, userId: Int) {}

    override fun onStateChanged(rtcSession: RTCSession, state: BaseSession.RTCSessionState) {
        // state was changed here
    }
})

To get current session state use:

val currentState = currentCall.state
mwaked commented 4 years ago

@TatankaConCube Okay thanks i will try this.