meetecho / janus-gateway

Janus WebRTC Server
https://janus.conf.meetecho.com
GNU General Public License v3.0
8.17k stars 2.47k forks source link

[Help] How to rejoin the audiobridge room when the user_id exists? #1767

Closed tesion99 closed 5 years ago

tesion99 commented 5 years ago

In the janus_audiobridge plugin, when a user with specific user_id rejoin the pocroom with new session, the previous participant with same user id can be found in audiobridge->participants. When the client reconnect the janus because of some network problem and the old session is not timeout, how can I clear the old session? I changed the code as follow

// janus_audiobridge.c : 3391
if(id) {
    user_id = json_integer_value(id);
    janus_audiobridge_participant *ex_pat= g_hash_table_lookup(audiobridge->participants, &user_id);
    gboolean removed = FALSE;
    if(ex_pat != NULL) {
        /* User ID already taken */
    JANUS_LOG(LOG_ERR, "User Id(%ld) already taken, close ex_participant...\n", user_id);
    janus_audiobridge_session *sess = ex_pat->session;
        // do like tick command
    if(sess) {
            gateway->close_pc(sess->handle);
    }
    removed = g_hash_table_remove(audiobridge->participants, &user_id);
    if (audiobridge != NULL) {
        janus_refcount_decrease(&audiobridge->ref);
    }
        if(removed) {
            janus_refcount_decrease(&ex_pat->ref);
    }
    // janus_mutex_unlock(&audiobridge->mutex);
    // janus_refcount_decrease(&audiobridge->ref);
    // JANUS_LOG(LOG_ERR, "User ID %"SCNu64" already exists\n", user_id);
    // error_code = JANUS_AUDIOBRIDGE_ERROR_ID_EXISTS;
    // g_snprintf(error_cause, 512, "User ID %"SCNu64" already exists", user_id);
    // goto error;
    }
}

but the janus will crash sometimes. How can audiobirdge clear resource of the old session ? Any ideas?

lminiero commented 5 years ago

As clearly explained in the guidelines, questions like these belong to the group: we only use Github for code related issues. Closing.

tesion99 commented 5 years ago

ok.