Reconnected immediately to the XMPP whenever it closes the connection

This commit is contained in:
Florent Le Coz
2014-03-24 20:31:02 +01:00
parent e196d2f1f4
commit ffc820e234
6 changed files with 46 additions and 0 deletions
+15
View File
@@ -30,6 +30,11 @@ static void character_data_handler(void *user_data, const XML_Char *s, int len)
XmppParser::XmppParser():
level(0),
current_node(nullptr)
{
this->init_xml_parser();
}
void XmppParser::init_xml_parser()
{
// Create the expat parser
this->parser = XML_ParserCreateNS("UTF-8", ':');
@@ -65,6 +70,16 @@ int XmppParser::parse(const int len, const bool is_final)
return res;
}
void XmppParser::reset()
{
XML_ParserFree(this->parser);
this->init_xml_parser();
if (this->current_node)
delete this->current_node;
this->current_node = nullptr;
this->level = 0;
}
void* XmppParser::get_buffer(const size_t size) const
{
return XML_GetBuffer(this->parser, static_cast<int>(size));