本文整理汇总了C++中CClient::GetNick方法的典型用法代码示例。如果您正苦于以下问题:C++ CClient::GetNick方法的具体用法?C++ CClient::GetNick怎么用?C++ CClient::GetNick使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CClient
的用法示例。
在下文中一共展示了CClient::GetNick方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
}
}
示例2: 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;
}
}
}
}
示例3: ReadLine
void CIRCSock::ReadLine(const CString& sData) {
CString sLine = sData;
sLine.TrimRight("\n\r");
DEBUG("(" << m_pUser->GetUserName() << ") IRC -> ZNC [" << sLine << "]");
MODULECALL(OnRaw(sLine), m_pUser, NULL, return);
if (sLine.Equals("PING ", false, 5)) {
// Generate a reply and don't forward this to any user,
// we don't want any PING forwarded
PutIRC("PONG " + sLine.substr(5));
return;
} else if (sLine.Token(1).Equals("PONG")) {
// Block PONGs, we already responded to the pings
return;
} else if (sLine.Equals("ERROR ", false, 6)) {
//ERROR :Closing Link: nick[24.24.24.24] (Excess Flood)
CString sError(sLine.substr(6));
if (sError.Left(1) == ":") {
sError.LeftChomp();
}
m_pUser->PutStatus("Error from Server [" + sError + "]");
return;
}
CString sCmd = sLine.Token(1);
if ((sCmd.length() == 3) && (isdigit(sCmd[0])) && (isdigit(sCmd[1])) && (isdigit(sCmd[2]))) {
CString sServer = sLine.Token(0); sServer.LeftChomp();
unsigned int uRaw = sCmd.ToUInt();
CString sNick = sLine.Token(2);
CString sRest = sLine.Token(3, true);
switch (uRaw) {
case 1: { // :irc.server.com 001 nick :Welcome to the Internet Relay Network nick
if (m_bAuthed && sServer == "irc.znc.in") {
// m_bAuthed == true => we already received another 001 => we might be in a traffic loop
m_pUser->PutStatus("ZNC seems to be connected to itself, disconnecting...");
Quit();
return;
}
m_pUser->SetIRCServer(sServer);
SetTimeout(240, TMO_READ); // Now that we are connected, let nature take its course
PutIRC("WHO " + sNick);
m_bAuthed = true;
m_pUser->PutStatus("Connected!");
vector<CClient*>& vClients = m_pUser->GetClients();
for (unsigned int a = 0; a < vClients.size(); a++) {
CClient* pClient = vClients[a];
CString sClientNick = pClient->GetNick(false);
if (!sClientNick.Equals(sNick)) {
// If they connected with a nick that doesn't match the one we got on irc, then we need to update them
pClient->PutClient(":" + sClientNick + "!" + m_Nick.GetIdent() + "@" + m_Nick.GetHost() + " NICK :" + sNick);
}
}
SetNick(sNick);
MODULECALL(OnIRCConnected(), m_pUser, NULL, );
m_pUser->ClearRawBuffer();
m_pUser->AddRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest);
CZNC::Get().ReleaseISpoof();
m_bISpoofReleased = true;
break;
}
case 5:
ParseISupport(sRest);
m_pUser->UpdateExactRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest);
break;
case 2:
case 3:
case 4:
case 250: // highest connection count
case 251: // user count
case 252: // oper count
case 254: // channel count
case 255: // client count
case 265: // local users
case 266: // global users
m_pUser->UpdateRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest);
break;
case 305:
m_pUser->SetIRCAway(false);
break;
case 306:
m_pUser->SetIRCAway(true);
break;
case 324: { // MODE
//.........这里部分代码省略.........
示例4: ReadLine
void CIRCSock::ReadLine(const CString& sData) {
CString sLine = sData;
sLine.TrimRight("\n\r");
DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/" << m_pNetwork->GetName() << ") IRC -> ZNC [" << sLine << "]");
NETWORKMODULECALL(OnRaw(sLine), m_pNetwork->GetUser(), m_pNetwork, NULL, return);
if (sLine.Equals("PING ", false, 5)) {
// Generate a reply and don't forward this to any user,
// we don't want any PING forwarded
PutIRC("PONG " + sLine.substr(5));
return;
} else if (sLine.Token(1).Equals("PONG")) {
// Block PONGs, we already responded to the pings
return;
} else if (sLine.Equals("ERROR ", false, 6)) {
//ERROR :Closing Link: nick[24.24.24.24] (Excess Flood)
CString sError(sLine.substr(6));
sError.TrimPrefix();
m_pNetwork->PutStatus("Error from Server [" + sError + "]");
return;
}
CString sCmd = sLine.Token(1);
if ((sCmd.length() == 3) && (isdigit(sCmd[0])) && (isdigit(sCmd[1])) && (isdigit(sCmd[2]))) {
CString sServer = sLine.Token(0).LeftChomp_n();
unsigned int uRaw = sCmd.ToUInt();
CString sNick = sLine.Token(2);
CString sRest = sLine.Token(3, true);
switch (uRaw) {
case 1: { // :irc.server.com 001 nick :Welcome to the Internet Relay Network nick
if (m_bAuthed && sServer == "irc.znc.in") {
// m_bAuthed == true => we already received another 001 => we might be in a traffic loop
m_pNetwork->PutStatus("ZNC seems to be connected to itself, disconnecting...");
Quit();
return;
}
m_pNetwork->SetIRCServer(sServer);
SetTimeout(540, TMO_READ); // Now that we are connected, let nature take its course
PutIRC("WHO " + sNick);
m_bAuthed = true;
m_pNetwork->PutStatus("Connected!");
vector<CClient*>& vClients = m_pNetwork->GetClients();
for (unsigned int a = 0; a < vClients.size(); a++) {
CClient* pClient = vClients[a];
CString sClientNick = pClient->GetNick(false);
if (!sClientNick.Equals(sNick)) {
// If they connected with a nick that doesn't match the one we got on irc, then we need to update them
pClient->PutClient(":" + sClientNick + "!" + m_Nick.GetIdent() + "@" + m_Nick.GetHost() + " NICK :" + sNick);
}
}
SetNick(sNick);
NETWORKMODULECALL(OnIRCConnected(), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING);
m_pNetwork->ClearRawBuffer();
m_pNetwork->AddRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest);
break;
}
case 5:
ParseISupport(sRest);
m_pNetwork->UpdateExactRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest);
break;
case 10: { // :irc.server.com 010 nick <hostname> <port> :<info>
CString sHost = sRest.Token(0);
CString sPort = sRest.Token(1);
CString sInfo = sRest.Token(2, true).TrimPrefix_n();
m_pNetwork->PutStatus("Server [" + m_pNetwork->GetCurrentServer()->GetString(false) +
"] redirects us to [" + sHost + ":" + sPort + "] with reason [" + sInfo + "]");
m_pNetwork->PutStatus("Perhaps you want to add it as a new server.");
// Don't send server redirects to the client
return;
}
case 2:
case 3:
case 4:
case 250: // highest connection count
case 251: // user count
case 252: // oper count
case 254: // channel count
case 255: // client count
case 265: // local users
case 266: // global users
m_pNetwork->UpdateRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest);
break;
case 305:
m_pNetwork->SetIRCAway(false);
break;
case 306:
//.........这里部分代码省略.........