本文整理汇总了C++中CIRCSock类的典型用法代码示例。如果您正苦于以下问题:C++ CIRCSock类的具体用法?C++ CIRCSock怎么用?C++ CIRCSock使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CIRCSock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Block
bool Block(const CString& sUser) {
CUser *pUser = CZNC::Get().FindUser(sUser);
if (!pUser)
return false;
// Disconnect all clients
vector<CClient*> vpClients = pUser->GetAllClients();
vector<CClient*>::iterator it;
for (it = vpClients.begin(); it != vpClients.end(); ++it) {
(*it)->PutStatusNotice(MESSAGE);
(*it)->Close(Csock::CLT_AFTERWRITE);
}
// Disconnect all networks from irc
vector<CIRCNetwork*> vNetworks = pUser->GetNetworks();
for (vector<CIRCNetwork*>::iterator it2 = vNetworks.begin(); it2 != vNetworks.end(); ++it2) {
CIRCNetwork *pNetwork = *it2;
CIRCSock *pIRCSock = pNetwork->GetIRCSock();
if (pIRCSock) {
pIRCSock->Quit();
}
}
// ...and don't reconnect
pUser->SetIRCConnectEnabled(false);
SetNV(pUser->GetUserName(), "");
return true;
}
示例2: RunJob
virtual void RunJob() {
vector<CIRCNetwork*> vNetworks = m_pUser->GetNetworks();
for (size_t a = 0; a < vNetworks.size(); a++) {
CIRCNetwork* pNetwork = vNetworks[a];
CIRCSock* pIRCSock = pNetwork->GetIRCSock();
if (pIRCSock && pIRCSock->GetTimeSinceLastDataTransaction() >= 270) {
pIRCSock->PutIRC("PING :ZNC");
}
if (pNetwork->IsIRCConnected()) {
pNetwork->JoinChans();
}
vector<CClient*>& vClients = pNetwork->GetClients();
for (size_t b = 0; b < vClients.size(); b++) {
CClient* pClient = vClients[b];
if (pClient->GetTimeSinceLastDataTransaction() >= 270) {
pClient->PutClient("PING :ZNC");
}
}
}
}
示例3: GetNick
CString GetNick() {
CString sConfNick = GetNetwork()->GetNick();
CIRCSock* pIRCSock = GetNetwork()->GetIRCSock();
if (pIRCSock) sConfNick = sConfNick.Left(pIRCSock->GetMaxNickLen());
return sConfNick;
}
示例4: GetIRCSock
bool CIRCNetwork::PutIRC(const CString& sLine) {
CIRCSock* pIRCSock = GetIRCSock();
if (!pIRCSock) {
return false;
}
pIRCSock->PutIRC(sLine);
return true;
}
示例5: GetAwayNick
CString GetAwayNick() {
size_t uLen = 9;
CIRCSock* pIRCSock = m_pUser->GetIRCSock();
if (pIRCSock) {
uLen = pIRCSock->GetMaxNickLen();
}
m_sAwayNick = m_pUser->ExpandString(m_sFormat).Left(uLen);
return m_sAwayNick;
}
示例6: GetAwayNick
CString GetAwayNick() {
unsigned int uLen = 9;
CIRCSock* pIRCSock = m_pNetwork->GetIRCSock();
if (pIRCSock) {
uLen = pIRCSock->GetMaxNickLen();
}
m_sAwayNick = m_pNetwork->ExpandString(m_sFormat).Left(uLen);
return m_sAwayNick;
}
示例7: StartBackNickTimer
void StartBackNickTimer() {
CIRCSock* pIRCSock = m_pUser->GetIRCSock();
if (pIRCSock) {
CString sConfNick = m_pUser->GetNick();
if (pIRCSock->GetNick().Equals(m_sAwayNick.Left(pIRCSock->GetNick().length()))) {
RemTimer("BackNickTimer");
AddTimer(new CBackNickTimer(*this));
}
}
}
示例8: GetCurrentServer
bool CIRCNetwork::DelServer(const CString& sName, unsigned short uPort, const CString& sPass) {
if (sName.empty()) {
return false;
}
unsigned int a = 0;
bool bSawCurrentServer = false;
CServer* pCurServer = GetCurrentServer();
for (vector<CServer*>::iterator it = m_vServers.begin(); it != m_vServers.end(); ++it, a++) {
CServer* pServer = *it;
if (pServer == pCurServer)
bSawCurrentServer = true;
if (!pServer->GetName().Equals(sName))
continue;
if (uPort != 0 && pServer->GetPort() != uPort)
continue;
if (!sPass.empty() && pServer->GetPass() != sPass)
continue;
m_vServers.erase(it);
if (pServer == pCurServer) {
CIRCSock* pIRCSock = GetIRCSock();
// Make sure we don't skip the next server in the list!
if (m_uServerIdx) {
m_uServerIdx--;
}
if (pIRCSock) {
pIRCSock->Quit();
PutStatus("Your current server was removed, jumping...");
}
} else if (!bSawCurrentServer) {
// Our current server comes after the server which we
// are removing. This means that it now got a different
// index in m_vServers!
m_uServerIdx--;
}
delete pServer;
return true;
}
return false;
}
示例9: GetPermChar
unsigned char CNick::GetPermChar() const {
CIRCSock* pIRCSock = (!m_pNetwork) ? NULL : m_pNetwork->GetIRCSock();
const CString& sChanPerms = (!pIRCSock) ? "@+" : pIRCSock->GetPerms();
for (unsigned int a = 0; a < sChanPerms.size(); a++) {
const unsigned char& c = sChanPerms[a];
if (HasPerm(c)) {
return c;
}
}
return '\0';
}
示例10: GetIRCSock
CString CUser::GetLocalIP() {
CIRCSock* pIRCSock = GetIRCSock();
if (pIRCSock) {
return pIRCSock->GetLocalIP();
}
if (!m_vClients.empty()) {
return m_vClients[0]->GetLocalIP();
}
return "";
}
示例11: GetNextServer
bool CIRCNetwork::Connect() {
if (!GetIRCConnectEnabled() || m_pIRCSock || !HasServers()) return false;
CServer* pServer = GetNextServer();
if (!pServer) return false;
if (CZNC::Get().GetServerThrottle(pServer->GetName())) {
// Can't connect right now, schedule retry later
CZNC::Get().AddNetworkToQueue(this);
return false;
}
CZNC::Get().AddServerThrottle(pServer->GetName());
bool bSSL = pServer->IsSSL();
#ifndef HAVE_LIBSSL
if (bSSL) {
PutStatus("Cannot connect to [" + pServer->GetString(false) +
"], ZNC is not compiled with SSL.");
CZNC::Get().AddNetworkToQueue(this);
return false;
}
#endif
CIRCSock* pIRCSock = new CIRCSock(this);
pIRCSock->SetPass(pServer->GetPass());
pIRCSock->SetSSLTrustedPeerFingerprints(m_ssTrustedFingerprints);
pIRCSock->SetTrustAllCerts(GetTrustAllCerts());
pIRCSock->SetTrustPKI(GetTrustPKI());
DEBUG("Connecting user/network [" << m_pUser->GetUserName() << "/"
<< m_sName << "]");
bool bAbort = false;
NETWORKMODULECALL(OnIRCConnecting(pIRCSock), m_pUser, this, nullptr,
&bAbort);
if (bAbort) {
DEBUG("Some module aborted the connection attempt");
PutStatus("Some module aborted the connection attempt");
delete pIRCSock;
CZNC::Get().AddNetworkToQueue(this);
return false;
}
CString sSockName = "IRC::" + m_pUser->GetUserName() + "::" + m_sName;
CZNC::Get().GetManager().Connect(pServer->GetName(), pServer->GetPort(),
sSockName, 120, bSSL, GetBindHost(),
pIRCSock);
return true;
}
示例12: KeepNick
void KeepNick() {
if (!m_pTimer)
// No timer means we are turned off
return;
CIRCSock* pIRCSock = GetNetwork()->GetIRCSock();
if (!pIRCSock) return;
// Do we already have the nick we want?
if (pIRCSock->GetNick().Equals(GetNick())) return;
PutIRC("NICK " + GetNick());
}
示例13: RunJob
void RunJob() override {
CIRCSock* pIRCSock = m_pNetwork->GetIRCSock();
if (pIRCSock && pIRCSock->GetTimeSinceLastDataTransaction() >= CIRCNetwork::PING_FREQUENCY) {
pIRCSock->PutIRC("PING :ZNC");
}
const vector<CClient*>& vClients = m_pNetwork->GetClients();
for (CClient* pClient : vClients) {
if (pClient->GetTimeSinceLastDataTransaction() >= CIRCNetwork::PING_FREQUENCY) {
pClient->PutClient("PING :ZNC");
}
}
}
示例14: GetPermStr
CString CNick::GetPermStr() const {
CIRCSock* pIRCSock = (!m_pUser) ? NULL : m_pUser->GetIRCSock();
const CString& sChanPerms = (!pIRCSock) ? "@+" : pIRCSock->GetPerms();
CString sRet;
for (unsigned int a = 0; a < sChanPerms.size(); a++) {
const unsigned char& c = sChanPerms[a];
if (HasPerm(c)) {
sRet += c;
}
}
return sRet;
}
示例15: GetTwitchNetwork
CModule::EModRet TwitchGroupChat::OnRawMessage(CMessage &msg)
{
if(msg.GetCommand().Equals("WHISPER"))
msg.SetCommand("PRIVMSG");
CString realNick = msg.GetTag("display-name").Trim_n();
if(realNick != "")
msg.GetNick().SetNick(realNick);
CIRCSock *twnw = GetTwitchNetwork();
if(twnw)
twnw->ReadLine(msg.ToString());
return CModule::CONTINUE;
}