Skip to content

Commit

Permalink
Adding error call back function with sendIQ()
Browse files Browse the repository at this point in the history
this will help to get the error message response by server.
If MAM service is not active in XMPP server, we will get the bellow kind of error message from server:

<iq xmlns="jabber:client" from="[email protected]" to="[email protected]/0F892479AD63271A1558-938994-148287" type="error" xml:lang="en" id="1:sendIQ">
   <query xmlns="urn:xmpp:mam:2">
      <x xmlns="jabber:x:data" type="submit">
         <field var="FORM_TYPE" type="hidden">
            <value>urn:xmpp:mam:2</value>
         </field>
         <field var="with">
            <value>[email protected]</value>
         </field>
         <field var="start">
            <value>2017-05-23T00:00:00Z</value>
         </field>
         <field var="end">
            <value>2017-05-26T00:00:00Z</value>
         </field>
      </x>
      <set xmlns="http://jabber.org/protocol/rsm">
         <max />
         <before />
      </set>
   </query>
   <error code="503" type="cancel">
      <service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
   </error>
</iq>
  • Loading branch information
debchy authored May 27, 2019
1 parent 0ab80c2 commit 5e628b9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/strophe.mam.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ Strophe.addConnectionPlugin('mam', {
return this._c.sendIQ(iq, function(){
_c.deleteHandler(handler);
onComplete.apply(this, arguments);
});
},
function(err){
//error callBack function
console.log("Error Response from server:", err);
});
}
});

0 comments on commit 5e628b9

Please sign in to comment.