本文整理汇总了C++中CBuffer::Size方法的典型用法代码示例。如果您正苦于以下问题:C++ CBuffer::Size方法的具体用法?C++ CBuffer::Size怎么用?C++ CBuffer::Size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBuffer
的用法示例。
在下文中一共展示了CBuffer::Size方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendBuffer
void CQuery::SendBuffer(CClient* pClient, const CBuffer& Buffer) {
if (m_pNetwork && m_pNetwork->IsUserAttached()) {
// Based on CChan::SendBuffer()
if (!Buffer.IsEmpty()) {
MCString msParams;
msParams["target"] = m_pNetwork->GetIRCNick().GetNick();
const vector<CClient*> & vClients = m_pNetwork->GetClients();
for (size_t uClient = 0; uClient < vClients.size(); ++uClient) {
CClient * pUseClient = (pClient ? pClient : vClients[uClient]);
size_t uSize = Buffer.Size();
for (size_t uIdx = 0; uIdx < uSize; uIdx++) {
CString sLine = Buffer.GetLine(uIdx, *pUseClient, msParams);
bool bContinue = false;
NETWORKMODULECALL(OnPrivBufferPlayLine(*pUseClient, sLine), m_pNetwork->GetUser(), m_pNetwork, NULL, &bContinue);
if (bContinue) continue;
m_pNetwork->PutUser(sLine, pUseClient);
}
if (pClient)
break;
}
}
}
}
示例2: CNetDDEPacket
inline CNetDDEPacket::CNetDDEPacket(uint nDataType, const CBuffer& oBuffer)
{
uint nPacketID = ASYNC_PACKET_ID;
if ((nDataType & PACKET_SYNC_MASK) == SYNC_PACKET)
nPacketID = GeneratePktID();
Create(nDataType, nPacketID, oBuffer.Buffer(), oBuffer.Size());
}
示例3: SendBuffer
void CQuery::SendBuffer(CClient* pClient, const CBuffer& Buffer) {
if (m_pNetwork && m_pNetwork->IsUserAttached()) {
// Based on CChan::SendBuffer()
if (!Buffer.IsEmpty()) {
const vector<CClient*> & vClients = m_pNetwork->GetClients();
for (CClient* pEachClient : vClients) {
CClient * pUseClient = (pClient ? pClient : pEachClient);
MCString msParams;
msParams["target"] = pUseClient->GetNick();
bool bWasPlaybackActive = pUseClient->IsPlaybackActive();
pUseClient->SetPlaybackActive(true);
bool bBatch = pUseClient->HasBatch();
CString sBatchName = m_sName.MD5();
if (bBatch) {
m_pNetwork->PutUser(":znc.in BATCH +" + sBatchName + " znc.in/playback " + m_sName, pUseClient);
}
size_t uSize = Buffer.Size();
for (size_t uIdx = 0; uIdx < uSize; uIdx++) {
const CBufLine& BufLine = Buffer.GetBufLine(uIdx);
if (!pUseClient->HasEchoMessage() && !pUseClient->HasSelfMessage()) {
CNick Sender(BufLine.GetFormat().Token(0));
if (Sender.NickEquals(pUseClient->GetNick())) {
continue;
}
}
CString sLine = BufLine.GetLine(*pUseClient, msParams);
if (bBatch) {
MCString msBatchTags = CUtils::GetMessageTags(sLine);
msBatchTags["batch"] = sBatchName;
CUtils::SetMessageTags(sLine, msBatchTags);
}
bool bContinue = false;
NETWORKMODULECALL(OnPrivBufferPlayLine2(*pUseClient, sLine, BufLine.GetTime()), m_pNetwork->GetUser(), m_pNetwork, nullptr, &bContinue);
if (bContinue) continue;
m_pNetwork->PutUser(sLine, pUseClient);
}
if (bBatch) {
m_pNetwork->PutUser(":znc.in BATCH -" + sBatchName, pUseClient);
}
pUseClient->SetPlaybackActive(bWasPlaybackActive);
if (pClient)
break;
}
}
}
}
示例4: Reader
CHandshakeReply::CHandshakeReply( CBuffer Packet )
{
_Packet = Packet;
FinalSize = Packet.Size() - 8;
PRW Reader(Packet);
Header = Reader.ReadBytes(11);
Data = Reader.ReadBuffer();
PubKey = Reader.ReadBuffer();
TQClient = Reader.ReadBytes(8);
FinalSize -= PubKey.Size();
cout << endl;
cout << "CHandshakeReply::DataLength = " << Data.Size() << endl;
cout << "CHandshakeReply::PubKeyLength = " << PubKey.Size() << endl;
cout << endl;
}
示例5: SendBuffer
void CQuery::SendBuffer(CClient* pClient, const CBuffer& Buffer) {
if (m_pNetwork && m_pNetwork->IsUserAttached()) {
// Based on CChan::SendBuffer()
if (!Buffer.IsEmpty()) {
MCString msParams;
msParams["target"] = m_pNetwork->GetIRCNick().GetNick();
const vector<CClient*> & vClients = m_pNetwork->GetClients();
for (size_t uClient = 0; uClient < vClients.size(); ++uClient) {
CClient * pUseClient = (pClient ? pClient : vClients[uClient]);
bool bBatch = pUseClient->HasBatch();
CString sBatchName = m_sName.MD5();
if (bBatch) {
m_pNetwork->PutUser(":znc.in BATCH +" + sBatchName + " znc.in/playback " + m_sName, pUseClient);
}
size_t uSize = Buffer.Size();
for (size_t uIdx = 0; uIdx < uSize; uIdx++) {
CString sLine = Buffer.GetLine(uIdx, *pUseClient, msParams);
if (bBatch) {
MCString msBatchTags = CUtils::GetMessageTags(sLine);
msBatchTags["batch"] = sBatchName;
CUtils::SetMessageTags(sLine, msBatchTags);
}
bool bContinue = false;
NETWORKMODULECALL(OnPrivBufferPlayLine(*pUseClient, sLine), m_pNetwork->GetUser(), m_pNetwork, NULL, &bContinue);
if (bContinue) continue;
m_pNetwork->PutUser(sLine, pUseClient);
}
if (bBatch) {
m_pNetwork->PutUser(":znc.in BATCH -" + sBatchName, pUseClient);
}
if (pClient)
break;
}
}
}
}
示例6: SaveBufferToDisk
void SaveBufferToDisk(const CBuffer& Buffer, const CString& sPath, const CString& sHeader)
{
CFile File(sPath);
CString sContent = sHeader + "\n";
size_t uSize = Buffer.Size();
for (unsigned int uIdx = 0; uIdx < uSize; uIdx++) {
const CBufLine& Line = Buffer.GetBufLine(uIdx);
timeval ts = Line.GetTime();
sContent +=
"@" + CString(ts.tv_sec) + "," + CString(ts.tv_usec) + " " +
Line.GetFormat() + "\n" +
Line.GetText() + "\n";
}
CBlowfish c(m_sPassword, BF_ENCRYPT);
sContent = c.Crypt(sContent);
if (File.Open(O_WRONLY | O_CREAT | O_TRUNC, 0600)) {
File.Chmod(0600);
File.Write(sContent);
}
File.Close();
}
示例7: SendBuffer
void CQuery::SendBuffer(CClient* pClient, const CBuffer& Buffer) {
if (m_pNetwork && m_pNetwork->IsUserAttached()) {
// Based on CChan::SendBuffer()
if (!Buffer.IsEmpty()) {
const vector<CClient*>& vClients = m_pNetwork->GetClients();
for (CClient* pEachClient : vClients) {
CClient* pUseClient = (pClient ? pClient : pEachClient);
MCString msParams;
msParams["target"] = pUseClient->GetNick();
bool bWasPlaybackActive = pUseClient->IsPlaybackActive();
pUseClient->SetPlaybackActive(true);
NETWORKMODULECALL(OnPrivBufferStarting(*this, *pUseClient),
m_pNetwork->GetUser(), m_pNetwork, nullptr,
NOTHING);
bool bBatch = pUseClient->HasBatch();
CString sBatchName = m_sName.MD5();
if (bBatch) {
m_pNetwork->PutUser(":znc.in BATCH +" + sBatchName +
" znc.in/playback " + m_sName,
pUseClient);
}
size_t uSize = Buffer.Size();
for (size_t uIdx = 0; uIdx < uSize; uIdx++) {
const CBufLine& BufLine = Buffer.GetBufLine(uIdx);
CMessage Message = BufLine.ToMessage(*pUseClient, msParams);
if (!pUseClient->HasEchoMessage() &&
!pUseClient->HasSelfMessage()) {
if (Message.GetNick().NickEquals(
pUseClient->GetNick())) {
continue;
}
}
Message.SetNetwork(m_pNetwork);
Message.SetClient(pUseClient);
if (bBatch) {
Message.SetTag("batch", sBatchName);
}
bool bContinue = false;
NETWORKMODULECALL(OnPrivBufferPlayMessage(Message),
m_pNetwork->GetUser(), m_pNetwork,
nullptr, &bContinue);
if (bContinue) continue;
m_pNetwork->PutUser(Message, pUseClient);
}
if (bBatch) {
m_pNetwork->PutUser(":znc.in BATCH -" + sBatchName,
pUseClient);
}
NETWORKMODULECALL(OnPrivBufferEnding(*this, *pUseClient),
m_pNetwork->GetUser(), m_pNetwork, nullptr,
NOTHING);
pUseClient->SetPlaybackActive(bWasPlaybackActive);
if (pClient) break;
}
}
}
}
示例8: OnDDEPoke
void CNetDDESvrApp::OnDDEPoke(CNetDDESvrSocket& oConnection, CNetDDEPacket& oReqPacket)
{
ASSERT(oReqPacket.DataType() == CNetDDEPacket::DDE_POKE);
bool bResult = false;
HCONV hConv;
uint32 nConvID;
CString strItem;
uint32 nFormat;
CBuffer oData;
// Decode message.
CMemStream oStream(oReqPacket.Buffer());
oStream.Open();
oStream.Seek(sizeof(CNetDDEPacket::Header));
oStream.Read(&hConv, sizeof(hConv));
oStream >> nConvID;
oStream >> strItem;
oStream >> nFormat;
oStream >> oData;
oStream.Close();
if (App.m_bTraceRequests)
{
CString strData;
if (nFormat == CF_TEXT)
strData = oData.ToString(ANSI_TEXT);
else if (nFormat == CF_UNICODETEXT)
strData = oData.ToString(UNICODE_TEXT);
else
strData = CClipboard::FormatName(nFormat);
App.Trace(TXT("DDE_POKE: %s %s [%s]"), strItem, CClipboard::FormatName(nFormat), strData);
}
try
{
// Locate the conversation.
CDDECltConv* pConv = m_pDDEClient->FindConversation(hConv);
if (pConv != NULL)
{
// Call DDE to do the poke.
pConv->Poke(strItem, nFormat, oData.Buffer(), oData.Size());
bResult = true;
}
}
catch (CDDEException& e)
{
App.Trace(TXT("DDE_ERROR: %s"), e.twhat());
}
// Create response message.
CBuffer oRspBuffer;
CMemStream oRspStream(oRspBuffer);
oRspStream.Create();
oRspStream << bResult;
oRspStream.Close();
// Send response message.
CNetDDEPacket oRspPacket(CNetDDEPacket::DDE_POKE, oReqPacket.PacketID(), oRspBuffer);
oConnection.SendPacket(oRspPacket);
// Update stats.
++m_nPktsSent;
}
示例9: SendBuffer
void CChan::SendBuffer(CClient* pClient, const CBuffer& Buffer) {
if (m_pNetwork && m_pNetwork->IsUserAttached()) {
// in the event that pClient is nullptr, need to send this to all
// clients for the user I'm presuming here that pClient is listed
// inside vClients thus vClients at this point can't be empty.
//
// This loop has to be cycled twice to maintain the existing behavior
// which is
// 1. OnChanBufferStarting
// 2. OnChanBufferPlayLine
// 3. ClearBuffer() if not keeping the buffer
// 4. OnChanBufferEnding
//
// With the exception of ClearBuffer(), this needs to happen per
// client, and if pClient is not nullptr, the loops break after the
// first iteration.
//
// Rework this if you like ...
if (!Buffer.IsEmpty()) {
const vector<CClient*>& vClients = m_pNetwork->GetClients();
for (CClient* pEachClient : vClients) {
CClient* pUseClient = (pClient ? pClient : pEachClient);
bool bWasPlaybackActive = pUseClient->IsPlaybackActive();
pUseClient->SetPlaybackActive(true);
bool bSkipStatusMsg = pUseClient->HasServerTime();
NETWORKMODULECALL(OnChanBufferStarting(*this, *pUseClient),
m_pNetwork->GetUser(), m_pNetwork, nullptr,
&bSkipStatusMsg);
if (!bSkipStatusMsg) {
m_pNetwork->PutUser(":***[email protected] PRIVMSG " + GetName() +
" :Buffer Playback...",
pUseClient);
}
bool bBatch = pUseClient->HasBatch();
CString sBatchName = GetName().MD5();
if (bBatch) {
m_pNetwork->PutUser(":znc.in BATCH +" + sBatchName +
" znc.in/playback " + GetName(),
pUseClient);
}
size_t uSize = Buffer.Size();
for (size_t uIdx = 0; uIdx < uSize; uIdx++) {
const CBufLine& BufLine = Buffer.GetBufLine(uIdx);
CMessage Message =
BufLine.ToMessage(*pUseClient, MCString::EmptyMap);
Message.SetChan(this);
Message.SetNetwork(m_pNetwork);
Message.SetClient(pUseClient);
if (bBatch) {
Message.SetTag("batch", sBatchName);
}
bool bNotShowThisLine = false;
NETWORKMODULECALL(OnChanBufferPlayMessage(Message),
m_pNetwork->GetUser(), m_pNetwork,
nullptr, &bNotShowThisLine);
if (bNotShowThisLine) continue;
m_pNetwork->PutUser(Message, pUseClient);
}
bSkipStatusMsg = pUseClient->HasServerTime();
NETWORKMODULECALL(OnChanBufferEnding(*this, *pUseClient),
m_pNetwork->GetUser(), m_pNetwork, nullptr,
&bSkipStatusMsg);
if (!bSkipStatusMsg) {
m_pNetwork->PutUser(":***[email protected] PRIVMSG " + GetName() +
" :Playback Complete.",
pUseClient);
}
if (bBatch) {
m_pNetwork->PutUser(":znc.in BATCH -" + sBatchName,
pUseClient);
}
pUseClient->SetPlaybackActive(bWasPlaybackActive);
if (pClient) break;
}
}
}
}
示例10: SendBuffer
void CChan::SendBuffer(CClient* pClient, const CBuffer& Buffer) {
if (m_pNetwork && m_pNetwork->IsUserAttached()) {
// in the event that pClient is NULL, need to send this to all clients for the user
// I'm presuming here that pClient is listed inside vClients thus vClients at this
// point can't be empty.
//
// This loop has to be cycled twice to maintain the existing behavior which is
// 1. OnChanBufferStarting
// 2. OnChanBufferPlayLine
// 3. ClearBuffer() if not keeping the buffer
// 4. OnChanBufferEnding
//
// With the exception of ClearBuffer(), this needs to happen per client, and
// if pClient is not NULL, the loops break after the first iteration.
//
// Rework this if you like ...
if (!Buffer.IsEmpty()) {
const vector<CClient*> & vClients = m_pNetwork->GetClients();
for (size_t uClient = 0; uClient < vClients.size(); ++uClient) {
CClient * pUseClient = (pClient ? pClient : vClients[uClient]);
bool bSkipStatusMsg = pUseClient->HasServerTime();
NETWORKMODULECALL(OnChanBufferStarting(*this, *pUseClient), m_pNetwork->GetUser(), m_pNetwork, NULL, &bSkipStatusMsg);
if (!bSkipStatusMsg) {
m_pNetwork->PutUser(":***[email protected] PRIVMSG " + GetName() + " :Buffer Playback...", pUseClient);
}
bool bBatch = pUseClient->HasBatch();
CString sBatchName = GetName().MD5();
if (bBatch) {
m_pNetwork->PutUser(":znc.in BATCH +" + sBatchName + " znc.in/playback " + GetName(), pUseClient);
}
size_t uSize = Buffer.Size();
for (size_t uIdx = 0; uIdx < uSize; uIdx++) {
CString sLine = Buffer.GetLine(uIdx, *pUseClient);
if (bBatch) {
MCString msBatchTags = CUtils::GetMessageTags(sLine);
msBatchTags["batch"] = sBatchName;
CUtils::SetMessageTags(sLine, msBatchTags);
}
bool bNotShowThisLine = false;
NETWORKMODULECALL(OnChanBufferPlayLine(*this, *pUseClient, sLine), m_pNetwork->GetUser(), m_pNetwork, NULL, &bNotShowThisLine);
if (bNotShowThisLine) continue;
m_pNetwork->PutUser(sLine, pUseClient);
}
bSkipStatusMsg = pUseClient->HasServerTime();
NETWORKMODULECALL(OnChanBufferEnding(*this, *pUseClient), m_pNetwork->GetUser(), m_pNetwork, NULL, &bSkipStatusMsg);
if (!bSkipStatusMsg) {
m_pNetwork->PutUser(":***[email protected] PRIVMSG " + GetName() + " :Playback Complete.", pUseClient);
}
if (bBatch) {
m_pNetwork->PutUser(":znc.in BATCH -" + sBatchName, pUseClient);
}
if (pClient)
break;
}
}
}
}