当前位置: 首页>>代码示例>>C++>>正文


C++ parsePacket函数代码示例

本文整理汇总了C++中parsePacket函数的典型用法代码示例。如果您正苦于以下问题:C++ parsePacket函数的具体用法?C++ parsePacket怎么用?C++ parsePacket使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parsePacket函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: xml

void TestPackets::testStreamFeatures()
{
    const QByteArray xml("<stream:features/>");
    QXmppStreamFeatures features;
    parsePacket(features, xml);
    QCOMPARE(features.bindMode(), QXmppStreamFeatures::Disabled);
    QCOMPARE(features.sessionMode(), QXmppStreamFeatures::Disabled);
    QCOMPARE(features.nonSaslAuthMode(), QXmppStreamFeatures::Disabled);
    QCOMPARE(features.tlsMode(), QXmppStreamFeatures::Disabled);
    QCOMPARE(features.authMechanisms(), QList<QXmppConfiguration::SASLAuthMechanism>());
    QCOMPARE(features.compressionMethods(), QList<QXmppConfiguration::CompressionMethod>());
    serializePacket(features, xml);

    const QByteArray xml2("<stream:features>"
        "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/>"
        "<session xmlns=\"urn:ietf:params:xml:ns:xmpp-session\"/>"
        "<auth xmlns=\"http://jabber.org/features/iq-auth\"/>"
        "<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>"
        "<compression xmlns=\"http://jabber.org/features/compress\"><method>zlib</method></compression>"
        "<mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"><mechanism>PLAIN</mechanism></mechanisms>"
        "</stream:features>");
    QXmppStreamFeatures features2;
    parsePacket(features2, xml2);
    QCOMPARE(features2.bindMode(), QXmppStreamFeatures::Enabled);
    QCOMPARE(features2.sessionMode(), QXmppStreamFeatures::Enabled);
    QCOMPARE(features2.nonSaslAuthMode(), QXmppStreamFeatures::Enabled);
    QCOMPARE(features2.tlsMode(), QXmppStreamFeatures::Enabled);
    QCOMPARE(features2.authMechanisms(), QList<QXmppConfiguration::SASLAuthMechanism>() << QXmppConfiguration::SASLPlain);
    QCOMPARE(features2.compressionMethods(), QList<QXmppConfiguration::CompressionMethod>() << QXmppConfiguration::ZlibCompression);
    serializePacket(features2, xml2);
}
开发者ID:contextlogger,项目名称:contextlogger2,代码行数:31,代码来源:tests.cpp

示例2: while

/// Blocks until either the stream encounters a pause mark or the sourceSocket errors.
/// This function is intended to be run after the 'q' command is sent, throwing away superfluous packets.
/// It will time out after 5 seconds, disconnecting the sourceSocket.
void DTSC::Stream::waitForPause(Socket::Connection & sourceSocket) {
  bool wasBlocking = sourceSocket.isBlocking();
  sourceSocket.setBlocking(false);
  //cancel the attempt after 5000 milliseconds
  long long int start = Util::getMS();
  while (lastType() != DTSC::PAUSEMARK && sourceSocket.connected() && Util::getMS() - start < 5000) {
    //we have data? parse it
    if (sourceSocket.Received().size()) {
      //return value is ignored because we're not interested.
      parsePacket(sourceSocket.Received());
    }
    //still no pause mark? check for more data
    if (lastType() != DTSC::PAUSEMARK) {
      if (sourceSocket.spool()) {
        //more received? attempt to read
        //return value is ignored because we're not interested in data packets, just metadata.
        parsePacket(sourceSocket.Received());
      } else {
        //nothing extra to receive? wait a bit and retry
        Util::sleep(10);
      }
    }
  }
  sourceSocket.setBlocking(wasBlocking);
  //if the timeout has passed, close the socket
  if (Util::getMS() - start >= 5000) {
    sourceSocket.close();
    //and optionally print a debug message that this happened
    DEBUG_MSG(DLVL_DEVEL, "Timing out while waiting for pause break");
  }
}
开发者ID:FihlaTV,项目名称:mistserver,代码行数:34,代码来源:dtsc.cpp

示例3: xml

void tst_QXmppMessage::testMessageReceipt()
{
    const QByteArray xml(
        "<message id=\"richard2-4.1.247\" to=\"[email protected]/throne\" from=\"[email protected]/westminster\" type=\"normal\">"
          "<body>My lord, dispatch; read o'er these articles.</body>"
          "<request xmlns=\"urn:xmpp:receipts\"/>"
        "</message>");

    QXmppMessage message;
    parsePacket(message, xml);
    QCOMPARE(message.id(), QString("richard2-4.1.247"));
    QCOMPARE(message.to(), QString("[email protected]/throne"));
    QCOMPARE(message.from(), QString("[email protected]/westminster"));
    QVERIFY(message.extendedAddresses().isEmpty());
    QCOMPARE(message.type(), QXmppMessage::Normal);
    QCOMPARE(message.body(), QString("My lord, dispatch; read o'er these articles."));
    QCOMPARE(message.isAttentionRequested(), false);
    QCOMPARE(message.isReceiptRequested(), true);
    QCOMPARE(message.receiptId(), QString());
    serializePacket(message, xml);

    const QByteArray receiptXml(
        "<message id=\"bi29sg183b4v\" to=\"[email protected]/westminster\" from=\"[email protected]/throne\" type=\"normal\">"
          "<received xmlns=\"urn:xmpp:receipts\" id=\"richard2-4.1.247\"/>"
        "</message>");

    QXmppMessage receipt;
    parsePacket(receipt, receiptXml);
    QCOMPARE(receipt.id(), QString("bi29sg183b4v"));
    QCOMPARE(receipt.to(), QString("[email protected]/westminster"));
    QCOMPARE(receipt.from(), QString("[email protected]/throne"));
    QVERIFY(receipt.extendedAddresses().isEmpty());
    QCOMPARE(receipt.type(), QXmppMessage::Normal);
    QCOMPARE(receipt.body(), QString());
    QCOMPARE(receipt.isAttentionRequested(), false);
    QCOMPARE(receipt.isReceiptRequested(), false);
    QCOMPARE(receipt.receiptId(), QString("richard2-4.1.247"));
    serializePacket(receipt, receiptXml);

    const QByteArray oldXml(
        "<message id=\"richard2-4.1.247\" to=\"[email protected]/westminster\" from=\"[email protected]/throne\" type=\"normal\">"
          "<received xmlns=\"urn:xmpp:receipts\"/>"
        "</message>");

    QXmppMessage old;
    parsePacket(old, oldXml);
    QCOMPARE(old.id(), QString("richard2-4.1.247"));
    QCOMPARE(old.to(), QString("[email protected]/westminster"));
    QCOMPARE(old.from(), QString("[email protected]/throne"));
    QVERIFY(old.extendedAddresses().isEmpty());
    QCOMPARE(old.type(), QXmppMessage::Normal);
    QCOMPARE(old.body(), QString());
    QCOMPARE(old.isAttentionRequested(), false);
    QCOMPARE(old.isReceiptRequested(), false);
    QCOMPARE(old.receiptId(), QString("richard2-4.1.247"));
}
开发者ID:unisontech,项目名称:qxmpp,代码行数:56,代码来源:tst_qxmppmessage.cpp

示例4: parsePacket

void tst_QXmppSasl::testSuccess()
{
    const QByteArray xml = "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"/>";
    QXmppSaslSuccess stanza;
    parsePacket(stanza, xml);
    serializePacket(stanza, xml);
}
开发者ID:fmoyaarnao,项目名称:qxmpp,代码行数:7,代码来源:tst_qxmppsasl.cpp

示例5: QFETCH

void tst_QXmppMessage::testBasic()
{
    QFETCH(QByteArray, xml);
    QFETCH(int, type);
    QFETCH(QString, body);
    QFETCH(QString, subject);
    QFETCH(QString, thread);

    QXmppMessage message;
    parsePacket(message, xml);
    QCOMPARE(message.to(), QString("[email protected]/QXmpp"));
    QCOMPARE(message.from(), QString("[email protected]/QXmpp"));
    QVERIFY(message.extendedAddresses().isEmpty());
    QCOMPARE(int(message.type()), type);
    QCOMPARE(message.body(), body);
    QCOMPARE(message.subject(), subject);
    QCOMPARE(message.thread(), thread);
    QCOMPARE(message.state(), QXmppMessage::None);
    QCOMPARE(message.isAttentionRequested(), false);
    QCOMPARE(message.isReceiptRequested(), false);
    QCOMPARE(message.hasForwarded(), false);
    QCOMPARE(message.receiptId(), QString());
    QCOMPARE(message.xhtml(), QString());
    serializePacket(message, xml);
}
开发者ID:freedbrt,项目名称:qxmpp,代码行数:25,代码来源:tst_qxmppmessage.cpp

示例6: replaceXml

void tst_QXmppMessage::testReplaceWithEmptyMessage()
{
    const QByteArray replaceXml(
                "<message to='[email protected]/balcony' id='good1'>"
                  "<body/>"
                  "<replace id='bad1' xmlns='urn:xmpp:message-correct:0'/>"
                "</message>");
    QXmppMessage replaceMessage;
    parsePacket(replaceMessage, replaceXml);
    QCOMPARE(replaceMessage.isReplace(), true);
    QCOMPARE(replaceMessage.replaceId(), QString("bad1"));
    QCOMPARE(replaceMessage.body(), QString(""));

    const QByteArray replaceSerialisation(
                "<message id=\"good1\" to=\"[email protected]/balcony\" type=\"chat\">"
                  "<body/>"
                  "<replace id=\"bad1\" xmlns=\"urn:xmpp:message-correct:0\"/>"
                "</message>");

    QXmppMessage serialisationMessage;
    serialisationMessage.setTo("[email protected]/balcony");
    serialisationMessage.setId("good1");
    serialisationMessage.setBody("");
    serialisationMessage.setReplace("bad1");

    serializePacket(serialisationMessage, replaceSerialisation);
}
开发者ID:freedbrt,项目名称:qxmpp,代码行数:27,代码来源:tst_qxmppmessage.cpp

示例7: xml

void tst_QXmppMessage::testProcessingHints()
{
    const QByteArray xml("<message "
                         "to=\"[email protected]/laptop\" "
                         "from=\"[email protected]/laptop\" "
                         "type=\"chat\">"
                       "<body>V unir avtug'f pybnx gb uvqr zr sebz gurve fvtug</body>"
                       "<no-copy xmlns=\"urn:xmpp:hints\"/>"
                       "<no-store xmlns=\"urn:xmpp:hints\"/>"
                       "<allow-permanent-storage xmlns=\"urn:xmpp:hints\"/>"
                     "</message>");

    QXmppMessage message;
    parsePacket(message, xml);
    QCOMPARE(message.hasHint(QXmppMessage::NoCopies), true);
    QCOMPARE(message.hasHint(QXmppMessage::NoStorage), true);
    QCOMPARE(message.hasHint(QXmppMessage::AllowPermantStorage), true);

    QXmppMessage message2;
    message2.setType(QXmppMessage::Chat);
    message2.setFrom(QString("[email protected]/laptop"));
    message2.setTo(QString("[email protected]/laptop"));
    message2.setBody(QString("V unir avtug'f pybnx gb uvqr zr sebz gurve fvtug"));
    message2.addHint(QXmppMessage::NoCopies);
    message2.addHint(QXmppMessage::NoStorage);
    message2.addHint(QXmppMessage::AllowPermantStorage);
    serializePacket(message2, xml);
}
开发者ID:freedbrt,项目名称:qxmpp,代码行数:28,代码来源:tst_qxmppmessage.cpp

示例8: xml

void tst_QXmppJingleIq::testCandidate()
{
    const QByteArray xml(
        "<candidate component=\"1\""
        " foundation=\"1\""
        " generation=\"0\""
        " id=\"el0747fg11\""
        " ip=\"10.0.1.1\""
        " network=\"1\""
        " port=\"8998\""
        " priority=\"2130706431\""
        " protocol=\"udp\""
        " type=\"host\"/>");

    QXmppJingleCandidate candidate;
    parsePacket(candidate, xml);
    QCOMPARE(candidate.foundation(), QLatin1String("1"));
    QCOMPARE(candidate.generation(), 0);
    QCOMPARE(candidate.id(), QLatin1String("el0747fg11"));
    QCOMPARE(candidate.host(), QHostAddress("10.0.1.1"));
    QCOMPARE(candidate.network(), 1);
    QCOMPARE(candidate.port(), quint16(8998));
    QCOMPARE(candidate.priority(), 2130706431);
    QCOMPARE(candidate.protocol(), QLatin1String("udp"));
    QCOMPARE(candidate.type(), QXmppJingleCandidate::HostType);
    serializePacket(candidate, xml);
};
开发者ID:gotomypc,项目名称:qxmpp,代码行数:27,代码来源:tst_qxmppjingleiq.cpp

示例9: xml

void tst_QXmppRegisterIq::testResult()
{
    const QByteArray xml(
        "<iq id=\"reg1\" type=\"result\">"
        "<query xmlns=\"jabber:iq:register\">"
        "<instructions>Choose a username and password for use with this service. Please also provide your email address.</instructions>"
        "<username/>"
        "<password/>"
        "<email/>"
        "</query>"
        "</iq>");

    QXmppRegisterIq iq;
    parsePacket(iq, xml);
    QCOMPARE(iq.id(), QLatin1String("reg1"));
    QCOMPARE(iq.to(), QString());
    QCOMPARE(iq.from(), QString());
    QCOMPARE(iq.type(), QXmppIq::Result);
    QCOMPARE(iq.instructions(), QLatin1String("Choose a username and password for use with this service. Please also provide your email address."));
    QVERIFY(!iq.username().isNull());
    QVERIFY(iq.username().isEmpty());
    QVERIFY(!iq.password().isNull());
    QVERIFY(iq.password().isEmpty());
    QVERIFY(!iq.email().isNull());
    QVERIFY(iq.email().isEmpty());
    QVERIFY(iq.form().isNull());
    serializePacket(iq, xml);
}
开发者ID:qxmpp-project,项目名称:qxmpp,代码行数:28,代码来源:tst_qxmppregisteriq.cpp

示例10: while

void sJarvisNode::parseBuffer(QString& buf)
{
    //qDebug() << "BufferStart:" << buf;
    //qDebug() << "-PacketSeparators:" << P_PACKETSTART << P_PACKETSEPARATOR << P_PACKETTERMINATOR;
    if(buf.length() == 0) return;
    int s_index = buf.indexOf(P_PACKETSTART);
    int e_index = buf.indexOf(P_PACKETTERMINATOR);
    //saneado del buffer
    //qDebug() << "indexs:" << s_index << "indexe" << e_index;
    if(s_index < 0)
    {// si no hay inicio de paquete lo que hay en el buffer tiene que ser basura.
        //qDebug() << "Limpiando Buffer";
        buf.clear();
        return;
    }
    //extraccion de comandos
    while ((s_index >= 0) && (e_index >= 0)) //Si hay inicio y fin de paquete se extrae el comando.
    {// lo que haya en el buffer hasta el inicio de paquete se descarta(basura)

        QString packet = buf.mid(s_index+1,e_index-s_index-1);
        parsePacket(packet);
        buf = buf.mid(e_index+1);
        s_index = buf.indexOf(P_PACKETSTART);
        e_index = buf.indexOf(P_PACKETTERMINATOR);
    }
    //qDebug() << "Buffer:End" << m_rxBuffer;
}
开发者ID:malfalf,项目名称:Jarvis,代码行数:27,代码来源:sjarvisnode.cpp

示例11: xml

void TestDiagnostics::testPacket()
{
    const QByteArray xml(
    "<iq type=\"result\">"
        "<query xmlns=\"http://wifirst.net/protocol/diagnostics\">"
            "<software type=\"os\" name=\"Windows\" version=\"XP\"/>"
            "<interface name=\"en1\">"
                "<address broadcast=\"\" ip=\"FE80:0:0:0:226:8FF:FEE1:A96B\" netmask=\"FFFF:FFFF:FFFF:FFFF:0:0:0:0\"/>"
                "<address broadcast=\"192.168.99.255\" ip=\"192.168.99.179\" netmask=\"255.255.255.0\"/>"
                "<wireless standards=\"ABGN\">"
                    "<network current=\"1\" cinr=\"-91\" rssi=\"-59\" ssid=\"Maki\"/>"
                    "<network cinr=\"-92\" rssi=\"-45\" ssid=\"freephonie\"/>"
                "</wireless>"
            "</interface>"
            "<lookup hostName=\"www.google.fr\">"
                "<address>2A00:1450:4007:800:0:0:0:68</address>"
                "<address>66.249.92.104</address>"
            "</lookup>"
            "<ping hostAddress=\"192.168.99.1\" minimumTime=\"1.657\" maximumTime=\"44.275\" averageTime=\"20.258\" sentPackets=\"3\" receivedPackets=\"3\"/>"
            "<traceroute hostAddress=\"213.91.4.201\">"
                "<ping hostAddress=\"192.168.99.1\" minimumTime=\"1.719\" maximumTime=\"4.778\" averageTime=\"3.596\" sentPackets=\"3\" receivedPackets=\"3\"/>"
            "</traceroute>"
        "</query>"
    "</iq>");

    DiagnosticsIq iq;
    parsePacket(iq, xml);
    serializePacket(iq, xml);
}
开发者ID:jlaine,项目名称:wilink,代码行数:29,代码来源:tests.cpp

示例12: printf

void EvaAgentDownloader::processTransferInfo( EvaFTAgentTransferReply * packet )
{
printf("EvaAgentDownloader::processTransferInfo\n");
	if(!parsePacket(packet)){
		m_State = EError;
		delete packet;
		return;
	}
	m_StartSequence = packet->getSequence();
	m_IsSendingStart = true;
	m_File->setCheckValues( packet->getFileNameMd5(), packet->getFileMd5());
	TQTextCodec *codec = TQTextCodec::codecForName("GB18030");
	m_FileName = codec->toUnicode(packet->getFileName().c_str());
	m_FileSize = packet->getFileSize();
	printf("EvaAgentDownloader:: -------------------- got info - file: %s, size: %d\n", 
				packet->getFileName().c_str(), m_FileSize);
	
	m_StartTime = TQDateTime::currentDateTime();
	if(!(m_File->setFileInfo(m_FileName, m_FileSize))){
		m_State = EError;
		delete packet;
		return;
	};
	if(m_File->loadInfoFile() && m_TransferType == TQQ_TRANSFER_FILE){
		notifyNormalStatus(ESResume);
		m_State = ENone;
		delete packet;
		return;
	}
	notifyTransferStatus();
	m_State = EInfoReady;
	delete packet;
}
开发者ID:MagicGroup,项目名称:eva,代码行数:33,代码来源:evafiledownloader.cpp

示例13: QFETCH

void tst_QXmppVCardIq::testAddress()
{
    QFETCH(QByteArray, xml);
    QFETCH(int, type);
    QFETCH(QString, country);
    QFETCH(QString, locality);
    QFETCH(QString, postcode);
    QFETCH(QString, region);
    QFETCH(QString, street);
    QFETCH(bool, equalsEmpty);

    QXmppVCardAddress address;
    parsePacket(address, xml);
    QCOMPARE(int(address.type()), type);
    QCOMPARE(address.country(), country);
    QCOMPARE(address.locality(), locality);
    QCOMPARE(address.postcode(), postcode);
    QCOMPARE(address.region(), region);
    QCOMPARE(address.street(), street);
    serializePacket(address, xml);

    QXmppVCardAddress addressCopy = address;
    QVERIFY2(addressCopy == address, "QXmppVCardAddres::operator==() fails");
    QVERIFY2(!(addressCopy != address), "QXmppVCardAddres::operator!=() fails");

    QXmppVCardAddress emptyAddress;
    QCOMPARE(emptyAddress == address, equalsEmpty);
    QCOMPARE(emptyAddress != address, !equalsEmpty);
}
开发者ID:ninoles,项目名称:qxmpp,代码行数:29,代码来源:tst_qxmppvcardiq.cpp

示例14: parsePacket

CCarProtocol::CCarProtocol(alt_u8 *pPacket, int iLength)
{
m_bValid = false;
m_bThereIsMore = false;

parsePacket(pPacket, iLength);
}
开发者ID:fjanssen,项目名称:Car2X,代码行数:7,代码来源:CarProtocol.cpp

示例15: xml1

void TestPackets::testNonSaslAuth()
{
    // Client Requests Authentication Fields from Server
    const QByteArray xml1(
        "<iq id=\"auth1\" to=\"shakespeare.lit\" type=\"get\">"
        "<query xmlns=\"jabber:iq:auth\"/>"
        "</iq>");

    QXmppNonSASLAuthIq iq1;
    parsePacket(iq1, xml1);
    serializePacket(iq1, xml1);

    // Client Provides Required Information (Plaintext)
    const QByteArray xml3(
        "<iq id=\"auth2\" type=\"set\">"
        "<query xmlns=\"jabber:iq:auth\">"
        "<username>bill</username>"
        "<password>Calli0pe</password>"
        "<resource>globe</resource>"
        "</query>"
        "</iq>");
    QXmppNonSASLAuthIq iq3;
    parsePacket(iq3, xml3);
    QCOMPARE(iq3.username(), QLatin1String("bill"));
    QCOMPARE(iq3.digest(), QByteArray());
    QCOMPARE(iq3.password(), QLatin1String("Calli0pe"));
    QCOMPARE(iq3.resource(), QLatin1String("globe"));
    serializePacket(iq3, xml3);

    // Client Provides Required Information (Plaintext)
    const QByteArray xml4(
        "<iq id=\"auth2\" type=\"set\">"
        "<query xmlns=\"jabber:iq:auth\">"
        "<username>bill</username>"
        "<digest>48fc78be9ec8f86d8ce1c39c320c97c21d62334d</digest>"
        "<resource>globe</resource>"
        "</query>"
        "</iq>");
    QXmppNonSASLAuthIq iq4;
    parsePacket(iq4, xml4);
    QCOMPARE(iq4.username(), QLatin1String("bill"));
    QCOMPARE(iq4.digest(), QByteArray("\x48\xfc\x78\xbe\x9e\xc8\xf8\x6d\x8c\xe1\xc3\x9c\x32\x0c\x97\xc2\x1d\x62\x33\x4d"));
    QCOMPARE(iq4.password(), QString());
    QCOMPARE(iq4.resource(), QLatin1String("globe"));
    serializePacket(iq4, xml4);
}
开发者ID:contextlogger,项目名称:contextlogger2,代码行数:46,代码来源:tests.cpp


注:本文中的parsePacket函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。