metajack / libstrophe

The libstrophe repository has moved to https://github.com/strophe/libstrophe
http://strophe.im/libstrophe
Other
135 stars 49 forks source link

Cannot add the same handler twice #51

Closed degaart closed 7 years ago

degaart commented 7 years ago

Calling xmpp_handler_add twice with the same handler but different userdata doesn't work. The second call is ignored.

I need it because I'm writing a C++ wrapper for libstrophe and handlers are implemented as pure virtual classes with a static member function as xmpp_handler, which means every handler callback function has the same memory address, only the userdata changes.

pasis commented 7 years ago

It doesn't work, because 2nd call of xmpp_handler_add() with the same handler function is ignored:

    /* check if handler already in list */
    for (item = conn->handlers; item; item = item->next) {
    if (item->handler == (void *)handler)
        break;
    }
    if (item) return;

Adding same handler function with different userdata makes sense. I will look into this.

And please, use https://github.com/strophe/libstrophe instead of current repository. libstrophe was moved there. Also recreate your ticket there.

degaart commented 7 years ago

Thank you pasis. I've recreated my ticked in the new repository