本文整理汇总了C++中InboundPkt类的典型用法代码示例。如果您正苦于以下问题:C++ InboundPkt类的具体用法?C++ InboundPkt怎么用?C++ InboundPkt使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InboundPkt类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: workNewSessionCreated
void Session::workNewSessionCreated(InboundPkt &inboundPkt, qint64 msgId) {
qCDebug(TG_CORE_SESSION) << "workNewSessionCreated: msgId =" << QString::number(msgId, 16);
mAsserter.check(inboundPkt.fetchInt() == (qint32)TL_NewSessionCreated);
inboundPkt.fetchLong(); // first_msg_id; //XXX set is as m_clientLastMsgId??
inboundPkt.fetchLong (); // unique_id
m_dc->setServerSalt(inboundPkt.fetchLong()); // server_salt
}
示例2: workUpdateShort
void Session::workUpdateShort(InboundPkt &inboundPkt, qint64 msgId) {
qCDebug(TG_CORE_SESSION) << "workUpdateShort: msgId =" << QString::number(msgId, 16);
mAsserter.check(inboundPkt.fetchInt() == (qint32)TL_UpdateShort);
Update update = inboundPkt.fetchUpdate();
qint32 date = inboundPkt.fetchInt();
Q_EMIT updateShort(update, date);
}
示例3: workBadMsgNotification
void Session::workBadMsgNotification(InboundPkt &inboundPkt, qint64 msgId) {
mAsserter.check(inboundPkt.fetchInt() == (qint32)TL_BadMsgNotification);
qint64 badMsgId = inboundPkt.fetchLong();
qint32 badMsgSeqNo = inboundPkt.fetchInt();
qint32 errorCode = inboundPkt.fetchInt();
qCWarning(TG_CORE_SESSION) << "workBadMsgNotification: badMsgId =" << QString::number(badMsgId, 16) <<
", badMsgSeqNo =" << badMsgSeqNo << ", errorCode =" << errorCode;
switch (errorCode) {
case 16:
case 17:
case 19:
case 32:
case 33:
case 64:
// update time sync difference and reset msgIds counter
qint32 serverTime = msgId >> 32LL;
mTimeDifference = QDateTime::currentDateTime().toTime_t() - serverTime;
qint64 nextId = generatePlainNextMsgId();
if (!m_pendingQueries.contains(nextId)) {
m_clientLastMsgId = 0;
}
// read removing from pending queries, recompose and send the last query
Query *q = m_pendingQueries.take(badMsgId);
qint64 newMsgId = recomposeAndSendQuery(q);
if (newMsgId != 0) {
Q_EMIT updateMessageId(badMsgId, newMsgId);
}
break;
}
}
示例4: workNewDetailedInfo
void Session::workNewDetailedInfo(InboundPkt &inboundPkt, qint64 msgId) {
qCDebug(TG_CORE_SESSION) << "workNewDetailedInfo: msgId =" << QString::number(msgId, 16);
mAsserter.check(inboundPkt.fetchInt() == (qint32)TL_MsgNewDetailedInfo);
inboundPkt.fetchLong(); // answer_msg_id
inboundPkt.fetchInt(); // bytes
inboundPkt.fetchInt(); // status
}
示例5: rpcExecuteAnswer
void Session::rpcExecuteAnswer(InboundPkt &inboundPkt, qint64 msgId) {
qint32 op = inboundPkt.prefetchInt();
qCDebug(TG_CORE_SESSION) << "rpcExecuteAnswer(), op =" << QString::number(op, 16);
switch (op) {
case TL_MsgContainer:
workContainer(inboundPkt, msgId);
return;
case TL_NewSessionCreated:
workNewSessionCreated(inboundPkt, msgId);
return;
case TL_MsgsAck:
workMsgsAck(inboundPkt, msgId);
return;
case TL_RpcResult:
workRpcResult(inboundPkt, msgId);
return;
case TL_UpdateShort:
workUpdateShort(inboundPkt, msgId);
return;
case TL_UpdatesCombined:
workUpdatesCombined(inboundPkt, msgId);
case TL_Updates:
workUpdates(inboundPkt, msgId);
return;
case TL_UpdateShortMessage:
workUpdateShortMessage(inboundPkt, msgId);
return;
case TL_UpdateShortChatMessage:
workUpdateShortChatMessage(inboundPkt, msgId);
return;
case TL_GZipPacked:
workPacked(inboundPkt, msgId);
return;
case TL_BadServerSalt:
workBadServerSalt(inboundPkt, msgId);
return;
case TL_Pong:
workPong(inboundPkt, msgId);
return;
case TL_MsgDetailedInfo:
workDetailedInfo(inboundPkt, msgId);
return;
case TL_MsgNewDetailedInfo:
workNewDetailedInfo(inboundPkt, msgId);
return;
case TL_UpdatesTooLong:
workUpdatesTooLong(inboundPkt, msgId);
return;
case TL_BadMsgNotification:
workBadMsgNotification(inboundPkt, msgId);
return;
}
qCWarning(TG_CORE_SESSION) << "Unknown rpc response message";
inboundPkt.setInPtr(inboundPkt.inEnd());
}
示例6: workRpcResult
void Session::workRpcResult(InboundPkt &inboundPkt, qint64 msgId) {
qCDebug(TG_CORE_SESSION) << "workRpcResult: msgId =" << QString::number(msgId, 16);
mAsserter.check(inboundPkt.fetchInt() == (qint32)TL_RpcResult);
qint64 id = inboundPkt.fetchLong();
qint32 op = inboundPkt.prefetchInt();
if (op == (qint32)TL_RpcError) {
queryOnError(inboundPkt, id);
} else {
queryOnResult(inboundPkt, id);
}
}
示例7: workBadServerSalt
void Session::workBadServerSalt(InboundPkt &inboundPkt, qint64 msgId) {
qCDebug(TG_CORE_SESSION) << "workBadServerSalt: msgId =" << QString::number(msgId, 16);
mAsserter.check(inboundPkt.fetchInt() == (qint32)TL_BadServerSalt);
qint64 badMsgId = inboundPkt.fetchLong();
inboundPkt.fetchInt(); // badMsgSeqNo
inboundPkt.fetchInt(); // errorCode
m_dc->setServerSalt(inboundPkt.fetchLong()); // new server_salt
// resend the last query
Query *q = m_pendingQueries.value(badMsgId);
if(q)
resendQuery(q);
}
示例8: queryOnError
void Session::queryOnError(InboundPkt &inboundPkt, qint64 msgId) {
mAsserter.check(inboundPkt.fetchInt() == TL_RpcError);
qint32 errorCode = inboundPkt.fetchInt();
QString errorText = inboundPkt.fetchQString();
qCDebug(TG_CORE_SESSION) << "error for query" << QString::number(msgId, 16) << " :" << errorCode << " :" << errorText;
Query *q = m_pendingQueries.take(msgId);
if (!q) {
qCWarning(TG_CORE_SESSION) << "No such query";
} else {
q->setAcked(true);
Q_EMIT errorReceived(q, errorCode, errorText);
}
}
示例9: workMsgsAck
void Session::workMsgsAck(InboundPkt &inboundPkt, qint64 msgId) {
qCDebug(TG_CORE_SESSION) << "workMsgsAck: msgId =" << QString::number(msgId, 16);
mAsserter.check(inboundPkt.fetchInt() == (qint32)TL_MsgsAck);
mAsserter.check(inboundPkt.fetchInt () == (qint32)TL_Vector);
qint32 n = inboundPkt.fetchInt();
for (qint32 i = 0; i < n; i++) {
qint64 id = inboundPkt.fetchLong ();
Query *q = m_pendingQueries.value(id);
if(!q)
return;
Q_ASSERT(q);
q->setAcked(true);
}
}
示例10: workBadServerSalt
void Session::workBadServerSalt(InboundPkt &inboundPkt, qint64 msgId) {
Q_UNUSED(msgId)
mAsserter.check(inboundPkt.fetchInt() == (qint32)TL_BadServerSalt);
qint64 badMsgId = inboundPkt.fetchLong();
qint32 badMsgSeqNo = inboundPkt.fetchInt();
qint32 errorCode = inboundPkt.fetchInt();
qCDebug(TG_CORE_SESSION) << "workBadServerSalt: badMsgId =" << QString::number(badMsgId, 16)
<< ", badMsgSeqNo =" << badMsgSeqNo << ", errorCode =" << errorCode;
m_dc->setServerSalt(inboundPkt.fetchLong()); // new server_salt
Query *q = m_pendingQueries.take(badMsgId);
qint64 newMsgId = recomposeAndSendQuery(q);
if (newMsgId != 0) {
Q_EMIT updateMessageId(badMsgId, newMsgId);
}
}
示例11: workPacked
void Session::workPacked(InboundPkt &inboundPkt, qint64 msgId) {
qCDebug(TG_CORE_SESSION) << "workPacked: msgId =" << QString::number(msgId, 16);
mAsserter.check(inboundPkt.fetchInt() == (qint32)TL_GZipPacked);
static qint32 buf[MAX_PACKED_SIZE >> 2];
qint32 l = inboundPkt.prefetchStrlen();
char *s = inboundPkt.fetchStr(l);
qint32 totalOut = Utils::tinflate(s, l, buf, MAX_PACKED_SIZE);
qint32 *inPtr = inboundPkt.inPtr();
qint32 *inEnd = inboundPkt.inEnd();
inboundPkt.setInPtr(buf);
inboundPkt.setInEnd(inboundPkt.inPtr() + totalOut / 4);
qCDebug(TG_CORE_SESSION) << "Unzipped data";
rpcExecuteAnswer(inboundPkt, msgId);
inboundPkt.setInPtr(inPtr); //TODO Not sure about this operations of setting inPtr and inEnd after execute answer completion
inboundPkt.setInEnd(inEnd);
}
示例12: processRpcMessage
void Session::processRpcMessage(InboundPkt &inboundPkt) {
EncryptedMsg *enc = (EncryptedMsg *)inboundPkt.buffer();
qint32 len = inboundPkt.length();
const qint32 MINSZ = offsetof (EncryptedMsg, message);
const qint32 UNENCSZ = offsetof (EncryptedMsg, serverSalt);
qCDebug(TG_CORE_SESSION) << "processRpcMessage(), len=" << len;
if(len < MINSZ || (len & 15) != (UNENCSZ & 15))
return;
Q_ASSERT(m_dc->authKeyId());
mAsserter.check(enc->authKeyId == m_dc->authKeyId());
//msg_key is used to compute AES key and to decrypt the received message
mCrypto->initAESAuth(m_dc->authKey() + 8, enc->msgKey, AES_DECRYPT);
qint32 l = mCrypto->padAESDecrypt((char *)&enc->serverSalt, len - UNENCSZ, (char *)&enc->serverSalt, len - UNENCSZ);
Q_UNUSED(l);
Q_ASSERT(l == len - UNENCSZ);
if( !(!(enc->msgLen & 3) && enc->msgLen > 0 && enc->msgLen <= len - MINSZ && len - MINSZ - enc->msgLen <= 12) )
return;
//check msg_key is indeed equal to SHA1 of the plaintext obtained after decription (without final padding bytes).
static uchar sha1Buffer[20];
SHA1((uchar *)&enc->serverSalt, enc->msgLen + (MINSZ - UNENCSZ), sha1Buffer);
Q_ASSERT(!memcmp (&enc->msgKey, sha1Buffer + 4, 16));
if (m_dc->serverSalt() != enc->serverSalt) {
m_dc->setServerSalt(enc->serverSalt);
}
// check time synchronization
qint32 serverTime = enc->msgId >> 32LL;
qint32 clientTime = QDateTime::currentDateTime().toTime_t() - mTimeDifference;
if (clientTime <= serverTime - 30 || clientTime >= serverTime + 300) {
qCDebug(TG_CORE_SESSION) << "salt =" << enc->serverSalt << ", sessionId =" << QString::number(enc->sessionId, 16) << ", msgId =" << QString::number(enc->msgId, 16) << ", seqNo =" << enc->seqNo << ", serverTime =" << serverTime << ", clientTime =" << clientTime;
QString alert("Received message has too large difference between client and server dates - ");
if (clientTime <= serverTime -30) {
alert.append("the message has a date at least 30 seconds later in time than current date");
} else {
alert.append("the message was sent at least 300 seconds ago");
}
qCWarning(TG_CORE_SESSION) << alert;
}
inboundPkt.setInPtr(enc->message);
inboundPkt.setInEnd(inboundPkt.inPtr() + (enc->msgLen / 4));
qCDebug(TG_CORE_SESSION) << "received message id" << QString::number(enc->msgId, 16);
Q_ASSERT(l >= (MINSZ - UNENCSZ) + 8);
if (enc->msgId & 1) {
addToPendingAcks(enc->msgId);
}
mAsserter.check(m_sessionId == enc->sessionId);
rpcExecuteAnswer(inboundPkt, enc->msgId);
mAsserter.check(inboundPkt.inPtr() == inboundPkt.inEnd());
}
示例13: workBadMsgNotification
void Session::workBadMsgNotification(InboundPkt &inboundPkt, qint64 msgId) {
mAsserter.check(inboundPkt.fetchInt() == (qint32)TL_BadMsgNotification);
qint64 badMsgId = inboundPkt.fetchLong();
qint32 badMsgSeqNo = inboundPkt.fetchInt();
qint32 errorCode = inboundPkt.fetchInt();
qCWarning(TG_CORE_SESSION) << "workBadMsgNotification: msgId =" << badMsgId <<
", seqNo =" << badMsgSeqNo << ", errorCode =" << errorCode;
switch (errorCode) {
case 16:
case 17:
// update time sync difference and reset msgIds counter
qint32 serverTime = msgId >> 32LL;
mTimeDifference = QDateTime::currentDateTime().toTime_t() - serverTime;
m_clientLastMsgId = 0;
// read removing from pending queries, recompose and send the last query
Query *q = m_pendingQueries.take(badMsgId);
recomposeAndSendQuery(q);
break;
}
}
示例14: queryOnResult
void Session::queryOnResult(InboundPkt &inboundPkt, qint64 msgId) {
qCDebug(TG_CORE_SESSION) << "result for query" << QString::number(msgId, 16);
qint32 op = inboundPkt.prefetchInt();
qint32 *inPtr = 0;
qint32 *inEnd = 0;
if (op == (qint32)TL_GZipPacked) {
inboundPkt.fetchInt();
qint32 l = inboundPkt.prefetchStrlen();
char *s = inboundPkt.fetchStr(l);
static qint32 packedBuffer[MAX_PACKED_SIZE / 4];
qint32 totalOut = Utils::tinflate (s, l, packedBuffer, MAX_PACKED_SIZE);
inPtr = inboundPkt.inPtr();
inEnd = inboundPkt.inEnd();
inboundPkt.setInPtr(packedBuffer);
inboundPkt.setInEnd(inboundPkt.inPtr() + totalOut / 4);
qCDebug(TG_CORE_SESSION) << "unzipped data";
}
Query *q = m_pendingQueries.take(msgId);
if (!q) {
qCWarning(TG_CORE_SESSION) << "No such query";
inboundPkt.setInPtr(inboundPkt.inEnd());
} else {
qCDebug(TG_CORE_SESSION) << "acked query with msgId" << QString::number(msgId, 16) << ",pendingQueries:" << m_pendingQueries.size();
q->setAcked(true);
Q_EMIT resultReceived(q, inboundPkt);
}
if (inPtr) {
inboundPkt.setInPtr(inPtr);
inboundPkt.setInEnd(inEnd);
}
}
示例15: workUpdatesTooLong
void Session::workUpdatesTooLong(InboundPkt &inboundPkt, qint64 msgId) {
qCDebug(TG_CORE_SESSION) << "workUpdatesTooLong: msgId =" << QString::number(msgId, 16);
mAsserter.check(inboundPkt.fetchInt() == (qint32)TL_UpdatesTooLong);
Q_EMIT updatesTooLong();
}