Conference_joined

Hi there,
i’m trying to subscribe some events in my self hosting jitsi (docker) like this:

APP.conference._room.on(JitsiMeetJS.events.conference.CONFERENCE_LEFT, _conference_left);

        APP.conference._room.on(JitsiMeetJS.events.conference.USER_LEFT, _conference_user_left);
        APP.conference._room.on(JitsiMeetJS.events.conference.USER_JOINED, _conference_user_joined);

        APP.conference._room.on(JitsiMeetJS.events.conference.CONFERENCE_JOINED, _conference_joined);

Everythings works fine but the listener CONFERENCE_JOINED.
Can anybody help me?

Other thing is this message:

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 conference.userLeft listeners added. Use emitter.setMaxListeners() to increase limit

how can i change this maximum?

Thank you.

We may need to see more of you code. I don’t see why you would have more than 1 conference.userLeft listener.

I just created 1. I think the others are the app who creates.

I’d have to see more of your code to really help. is the function _conference_joined defined?

function sendPostClose()

{

     sendPostMessage({ type: 'close-conference', scope: 'conference' });

}

function redirect_error()

{

    var error_page = document.getElementById('redirectPageMessage');

    error_page.style.display = "block"; 

     //var aaa = document.getElementById('modal-dialog-cancel-button');

     //aaa.click();

   // window.location.href = "static/error.html";

}

function _conference_failed()

{

    sendPostMessage({ type: 'close-conference', scope: 'conference' });

}

function _conference_left() {

    console.log('I left the conference');

   sendPostMessage({ type: 'close-conference', scope: 'conference' });

}

function _conference_user_left(id) {

    if(APP.conference._room)

    {

        if(APP.conference.membersCount <= 1)

        {

            //clearInterval(time);

            verifyAloneInConference();

            //sendPostMessage({ type: 'close-conference', scope: 'conference' });

        }

    }

      console.log(id+' left the conference');

}

function _conference_user_joined(id,user)

{

    

    clearInterval(time);

    console.log('someone joined the conference');

}

 

function _conference_joined() {

        //if (window.APP.conference.membersCount <= 1)

           // sendPostMessage({ type: 'close-conference', scope: 'conference' });

        clearInterval(time);

        console.log('joined the conference');

}

function _connection_error()

{

    console.log('connection_error');

    redirect_error();

}

function sendPostMessage(data)

{

     window.parent.postMessage(data, ext_url);

}

function verifyAloneInConference()

{

    if(APP.conference.membersCount <= 1)

    {

        time = setInterval(timeToDisconnect, interval);

    }

    

}

function timeToDisconnect()

{

     clearInterval(time);

    console.log('hanged up');

    APP.conference.hangup();

}

function subscribeToEvents() {

    try {

        if (!APP.store.getState()) {

            throw new Error("state is not ready. try again");

        } else if (!APP.store.getState()["features/base/connection"]) {

            throw new Error("connection is not ready. try again");

        }

        cnn = APP.store.getState()["features/base/connection"];

        if (cnn.error) {

           _connection_error();

        }

        APP.conference._room.on(JitsiMeetJS.events.conference.CONFERENCE_FAILED, _conference_failed);

        APP.conference._room.on(JitsiMeetJS.events.conference.CONFERENCE_ERROR, _conference_failed);

        //APP.conference._room.on("conference.kicked", redirect);

        APP.conference._room.on(JitsiMeetJS.events.conference.CONFERENCE_LEFT, _conference_left);

        APP.conference._room.on(JitsiMeetJS.events.conference.USER_LEFT, _conference_user_left);

         APP.conference._room.on(JitsiMeetJS.events.conference.USER_JOINED, _conference_user_joined);

        APP.conference._room.on(JitsiMeetJS.events.conference.CONFERENCE_JOINED, _conference_joined);

        

        console.log(APP.conference.membersCount);

        clearInterval(time);

        verifyAloneInConference();

    } catch (e) {

        setTimeout(() => subscribeToEvents(), 3000);

    }

}

If I had to guess, without running your code, subscribeToEvents() is being called after CONFERENCE_JOINED has already been fired.

I believe the only check you need before adding the events is:

...
if (typeof APP !== "undefined" && 
    typeof APP.conference !== "undefined" &&
    typeof APP.conference._room !== "undefined")
{
   // okay to attach listeners now
...

Similar to this post.

Also I see why you have a MaxListenersExceededWarning for the 11 listeners added for conference.userLeft - it’s because you are listening again each time you call subscribeToEvents(). Consider always calling .off(...) before calling .on(...).

Like this:

//Remove your listener
APP.conference._room.off(JitsiMeetJS.events.conference.CONFERENCE_FAILED, _conference_failed);

//Add your listener
APP.conference._room.off(JitsiMeetJS.events.conference.CONFERENCE_FAILED, _conference_failed);

If I had to guess, without running your code, subscribeToEvents() is being called after CONFERENCE_JOINED has already been fired.

I believe the only check you need before adding the events is:

You’re right. Thank you.

Also I see why you have a MaxListenersExceededWarning for the 11 listeners added for conference.userLeft - it’s because you are listening again each time you call subscribeToEvents() . Consider always calling .off(...) before calling .on(...) .

I think this is inherent to Jitsi. When my subscribeToEvents adds the listener, i will only runs once.