0

Conversation not found error , when both person already did conversation ago but in error method I am creating new conversation but still both not connect each other

    conversationsClient!!.getConversation(
        roomName,
        object : CallbackListener<Conversation?> {
            override fun onSuccess(conversation: Conversation?) {
                if (conversation != null) {
                    if (conversation.status == Conversation.ConversationStatus.JOINED) {
                        Log.d(
                            "TAG",
                            "Already Exists in Conversation: $roomName"
                        )
                        this@QuickstartConversationsManager.conversation = conversation
                        this@QuickstartConversationsManager.conversation!!.addListener(
                            mDefaultConversationListener
                        )
                        loadPreviousMessages(conversation)
                    } else {
                        Log.d(
                            "TAG",
                            "Joining Conversation: $roomName"
                        )
                        joinConversation(conversation)
                    }
                }
            }

            override fun onError(errorInfo: ErrorInfo) {
                Log.e("TAG", "Error retrieving conversation: ${errorInfo.message}")
                createConversation()
            }
        })

private fun createConversation() {
    Log.d("TAG", "Creating Conversation: $roomName")

    conversationsClient!!.createConversation(
        roomName,
        object : CallbackListener<Conversation> {
            override fun onSuccess(conversation: Conversation) {

                Log.d(
                    "TAG",
                    "Joining Conversation: $roomName"
                )

                // here i need to add participant
                if (isPatient){
                    Log.d("TAG", "onSuccess: doctorUserNAme $participantName")
                    conversation.addParticipantByIdentity(participantName,null,null)
                }else{
                    Log.d("TAG", "onSuccess: patientUserNAme $participantName")
                    conversation.addParticipantByIdentity(participantName,null,null)
                }

                joinConversation(conversation)
            }

            override fun onError(errorInfo: ErrorInfo) {
                Log.e("TAG", "Error creating conversation: " + errorInfo.message)
            }
        })
}

private fun joinConversation(conversation: Conversation) {
    Log.d("TAG", "Joining Conversation: ${conversation.status}")

    if (conversation.status == Conversation.ConversationStatus.JOINED) {
        this@QuickstartConversationsManager.conversation = conversation
        Log.d("TAG", "Already joined default conversation")
        this@QuickstartConversationsManager.conversation!!.addListener(
            mDefaultConversationListener
        )
        return
    }

    conversation.join(object : StatusListener {
        override fun onSuccess() {
            Log.d("TAG", "onSuccess: ${conversation.status}")
            this@QuickstartConversationsManager.conversation = conversation
            Log.d("TAG", "Joined conversation ")
            this@QuickstartConversationsManager.conversation!!.addListener(
                mDefaultConversationListener
            )
            loadPreviousMessages(conversation)
        }

        override fun onError(errorInfo: ErrorInfo) {
            Log.e("TAG", "Error joining conversation: " + errorInfo.message + errorInfo.code)
        }
    })
}

joinconversation() method is working but both are not connecting each other and I want to connect both each other , and after connect the eachother get the older messages

RF1991
  • 2,037
  • 4
  • 8
  • 17

0 Answers0