void TelnetFilter::analyzeMudStream(const char *input, int length) { QByteArray ba = QByteArray::fromRawData(input, length); dispatchTelnetStream(ba, m_mudIncomingData, m_mudIncomingQue); IncomingData data; while ( !m_mudIncomingQue.isEmpty() ) { data = m_mudIncomingQue.dequeue(); //parse incoming lines in que emit parseNewMudInputXml(data/*m_mudIncomingQue*/); } return; }
void TelnetFilter::analyzeMudStream(const char * input, int length) { //QByteArray ba(input, length); QByteArray ba = QByteArray::fromRawData(input, length); dispatchTelnetStream(ba, m_mudIncomingData, m_mudIncomingQue); /* if(!m_xmlModeAutoconfigured) { QByteArray line; TelnetDataType type; for (int i = 0; i < m_mudIncomingQue.size(); ++i) { line = m_mudIncomingQue.at(i).line; type = m_mudIncomingQue.at(i).type; if (type == TDT_CRLF || type == TDT_LF || type == TDT_LFCR || type == TDT_PROMPT) { //QByteArray ba = line.toAscii(); //quint8* dataline = (quint8*) line.data(); if (line.contains("Reconnecting.")) m_reconnecting = true; if (line.contains("<xml>") || line.contains("room>") || line.contains("prompt>") || line.contains("<movement")) { m_xmlMode = true; m_xmlModeAutoconfigured = true; emit sendToMud((QByteArray)"brief\n"); emit sendToMud((QByteArray)"prompt all\n"); if (Config().m_IAC_prompt_parser) { //send IAC-GA prompt request QByteArray idprompt("~$#EP2\nG\n"); emit sendToMud(idprompt); } break; } else if (m_reconnecting && (line.contains(">")) || line.contains("Exits")) { m_xmlMode = false; m_xmlModeAutoconfigured = true; emit sendToMud((QByteArray)"brief\n"); emit sendToMud((QByteArray)"prompt all\n"); if (Config().m_IAC_prompt_parser) { //send IAC-GA prompt request QByteArray idprompt("~$#EP2\nG\n"); emit sendToMud(idprompt); } break; } } } } */ IncomingData data; while ( !m_mudIncomingQue.isEmpty() ) { data = m_mudIncomingQue.dequeue(); if(!m_xmlModeAutoconfigured && (data.type == TDT_CRLF || data.type == TDT_LF || data.type == TDT_LFCR || data.type == TDT_PROMPT)) { if (data.line.contains("Reconnecting.")) m_reconnecting = true; if (data.line.contains("<xml>") || data.line.contains("name>") || data.line.contains("room>") || data.line.contains("prompt>") || data.line.contains("movement")) { m_xmlMode = true; m_xmlModeAutoconfigured = true; //emit sendToMud((QByteArray)"brief\n"); //emit sendToMud((QByteArray)"prompt all\n"); } // XXX: fixed (I think) the logic in the line below. Not sure it's right. // Alternative: ( recon && > ) || exits else if (m_reconnecting && ( data.line.contains(">") || data.line.contains("Exits") ) ) { m_xmlMode = false; m_xmlModeAutoconfigured = true; //emit sendToMud((QByteArray)"brief\n"); emit sendToMud((QByteArray)"prompt all\n"); } } //parse incoming lines in que if (m_xmlMode) emit parseNewMudInputXml(data/*m_mudIncomingQue*/); else emit parseNewMudInput(data/*m_mudIncomingQue*/); } return; }