本文整理汇总了C++中serializePacket函数的典型用法代码示例。如果您正苦于以下问题:C++ serializePacket函数的具体用法?C++ serializePacket怎么用?C++ serializePacket使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了serializePacket函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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"));
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: sendPackets
void* sendPackets(void* data) {
// Send Header
Header* h = initHeader(filename, "dave");
char* h_s = serializeHeader(h);
sendto(sock, h_s, strlen(h_s), 0, (struct sockaddr *) &servAddr, sizeof(servAddr));
// Send the packets
for (;;) {
if (!isEmpty(ph)) {
char *s;
Packet* p = malloc(sizeof(Packet));
getLock(ph);
p = removePacket(ph, p); // Get packet
unlock(ph);
s = serializePacket(p); // Convert into sendable char array
sendto(sock, s, strlen(s), 0, (struct sockaddr *) &servAddr, sizeof(servAddr));
if (p->fragment == DUMMY_FRAG_NUM) {
printf("Done Sending!!\n");
pthread_exit(0);
}
}
}
}
示例6: 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);
};
示例7: 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);
}
示例8: 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);
}
示例9: xml
void TestPubSub::testSubscription()
{
const QByteArray xml(
"<iq"
" id=\"sub1\""
" to=\"[email protected]/barracks\""
" from=\"pubsub.shakespeare.lit\""
" type=\"result\">"
"<pubsub xmlns=\"http://jabber.org/protocol/pubsub\">"
"<subscription jid=\"[email protected]\""
" node=\"princely_musings\""
" subid=\"ba49252aaa4f5d320c24d3766f0bdcade78c78d3\""
" subscription=\"subscribed\"/>"
"</pubsub>"
"</iq>");
QXmppPubSubIq iq;
parsePacket(iq, xml);
QCOMPARE(iq.id(), QLatin1String("sub1"));
QCOMPARE(iq.to(), QLatin1String("[email protected]/barracks"));
QCOMPARE(iq.from(), QLatin1String("pubsub.shakespeare.lit"));
QCOMPARE(iq.type(), QXmppIq::Result);
QCOMPARE(iq.queryType(), QXmppPubSubIq::SubscriptionQuery);
QCOMPARE(iq.queryJid(), QLatin1String("[email protected]"));
QCOMPARE(iq.queryNode(), QLatin1String("princely_musings"));
QCOMPARE(iq.subscriptionId(), QLatin1String("ba49252aaa4f5d320c24d3766f0bdcade78c78d3"));
serializePacket(iq, xml);
}
示例10: 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);
}
示例11: 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);
}
示例12: 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);
}
示例13: QFETCH
void tst_QXmppMessage::testState()
{
QFETCH(QByteArray, xml);
QFETCH(int, state);
QXmppMessage message;
parsePacket(message, xml);
QCOMPARE(int(message.state()), state);
serializePacket(message, xml);
}
示例14: serializePacket
void
DebugNet::writePacket(DebugPacket *pak)
{
gLog->debug("Writing packet {}", (int)pak->type());
std::vector<uint8_t> buffer;
serializePacket(buffer, pak);
SOCKET sock = (SOCKET)mSocket;
send(sock, (char*)&buffer[0], (int)buffer.size(), 0);
}
示例15: QFETCH
void tst_QXmppSasl::testChallenge()
{
QFETCH(QByteArray, xml);
QFETCH(QByteArray, value);
// no condition
QXmppSaslChallenge challenge;
parsePacket(challenge, xml);
QCOMPARE(challenge.value(), value);
serializePacket(challenge, xml);
}