ConnectyCube / connectycube-reactnative-samples

Chat and Video Chat code samples for React Native, ConnectyCube
https://connectycube.com
Apache License 2.0
125 stars 111 forks source link

How to remove listeners #119

Closed AbhiSri2020 closed 3 years ago

AbhiSri2020 commented 3 years ago

I am using the sample code provided in the master branch and made some changes so now I have same kind of listeners set up at different screens, as

Parrent has listeners: _onCallListener, _onAcceptCallListener, this._onRejectCallListener, this._onStopCallListener, this._onUserNotAnswerListener, _onRemoteStreamListener and grandchild also has the same listeners except for _onCallListener.

parent's componentDidMount code

        ConnectyCube.videochat.onCallListener = this._onCallListener;
        ConnectyCube.videochat.onAcceptCallListener = this._onAcceptCallListener;
        ConnectyCube.videochat.onRejectCallListener = this._onRejectCallListener;
        ConnectyCube.videochat.onStopCallListener = this._onStopCallListener;
        ConnectyCube.videochat.onUserNotAnswerListener = this._onUserNotAnswerListener;
        ConnectyCube.videochat.onRemoteStreamListener = this._onRemoteStreamListener;

grandchild componentDidMount code (_onCallListener is not present here)

        ConnectyCube.videochat.onAcceptCallListener = this._onAcceptCallListener;
        ConnectyCube.videochat.onRejectCallListener = this._onRejectCallListener;
        ConnectyCube.videochat.onStopCallListener = this._onStopCallListener;
        ConnectyCube.videochat.onUserNotAnswerListener = this._onUserNotAnswerListener;
        ConnectyCube.videochat.onRemoteStreamListener = this._onRemoteStreamListener;

and conponentWillUnmount

        ConnectyCube.videochat._onAcceptCallListener = this._onAcceptCallListener
        ConnectyCube.videochat._onRejectCallListener = this._onRejectCallListener
        ConnectyCube.videochat._onStopCallListener = this._onStopCallListener
        ConnectyCube.videochat._onUserNotAnswerListener = this._onUserNotAnswerListener
        ConnectyCube.videochat._onRemoteStreamListener = this._onRemoteStreamListener

but when I unmount the grandChild and moved to the parent screen then also grandChild's _onRemoteStreamListener is called instead of the parent's _onRemoteStreamListener.

banshiAnton commented 3 years ago

Hi @AbhiSri2020 our sdk architecture does not provide that you have more then one videochat listeners You need to set up all listeners in one place (it can be service) in your app

banshiAnton commented 3 years ago

Hi @AbhiSri2020 do you need help ?

aravi365 commented 3 years ago

Hi @AbhiSri2020 do you need help ?

@banshiAnton could you please help me to write the listeners for functional components