It appears that when the addHandler function is called the stack (an array containing all the handlers to be called), it is empty when the handlers are executed. Therefore, when the node method that matches the conditions of the handler is called the stack, it is cleared, and then the other nodes will not be found, so you need to install the handler again or add handlers that you expect to call as follows:
connection.addHandler(testHandler,null,"presence"); connection.addHandler(testHandler,null,"presence"); connection.addHandler(testHandler,null,"presence");
or
connection.addHandler(testHandler,null,"presence"); function testHandler(stanza){ console.log(stanza); connection.addHandler(testHandler,null,"presence"); }
may not be the best solution, but I will use it until someone gives me the best one, anyway I will post this workaround to give an idea of ββthe code stream I am dealing with.
change
Read the documentation at http://code.stanziq.com/strophe/strophejs/doc/1.0.1/files/core-js.html#Strophe.Connection.addHandler I found this line:
The handler should return true if it should be called again; return false will delete the handler after it returns.
Therefore, it will be fixed by adding only the line:
connection.addHandler(testHandler,null,"presence"); function testHandler(stanza){ console.log(stanza); return true; }
markcial
source share