metajack / strophejs

The Strophe.js repository has moved to https://github.com/strophe/strophejs

Home Page:http://strophe.im/strophejs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

addHandler issue on message

darshanopenxcell opened this issue · comments

Hi,

I am getting XML request but not getting message in addHandler message.

connection.addHandler(onMessage, null, 'message', null, null, null);
connection.send($pres().tree());

Message not come in this function function.
But i can see response from /http-bind/ like

hello

Please help me,
Thanks.

Please open issues in this repository instead: https://github.com/strophe/strophejs
this repository is not maintained any more

Also, you will have to be more precise with your issue.
How does the XML message look like?
Are these two lines actually after another this in the code? Then there is no reason why onMessage should be called.

XML message like

<body xmlns='http://jabber.org/protocol/httpbind'><message xmlns="jabber:client" to="xxx@xxxx.com" from="xxx@xxxx.com/78950f38" type="chat"><body>hello</body></message></body>

I am getting message in onMessage function and this function like this..

function onMessage(msg) {
    var to = msg.getAttribute('to');
    var from = msg.getAttribute('from');
    var type = msg.getAttribute('type');
    var elems = msg.getElementsByTagName('body');
        if (type == "chat" && elems.length > 0) {
        var body = elems[0];
        var nmsg = Strophe.getText(body);
        }
}