本文整理汇总了C++中SocketHandler::DownRef方法的典型用法代码示例。如果您正苦于以下问题:C++ SocketHandler::DownRef方法的具体用法?C++ SocketHandler::DownRef怎么用?C++ SocketHandler::DownRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SocketHandler
的用法示例。
在下文中一共展示了SocketHandler::DownRef方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleFileQuery
bool FileServerHandler::HandleFileQuery(SocketHandler *socket,
QStringList &slist)
{
QStringList res;
if (slist.size() != 4)
{
LOG(VB_GENERAL, LOG_ERR, QString("Invalid Request. %1")
.arg(slist.join("[]:[]")));
res << "EMPTY LIST";
socket->SendStringList(res);
return true;
}
QString wantHost = slist[1];
QString groupname = slist[2];
QString filename = slist[3];
LOG(VB_FILE, LOG_DEBUG, QString("HandleSGFileQuery: myth://%[email protected]%2/%3")
.arg(groupname).arg(wantHost).arg(filename));
if ((wantHost.toLower() == gCoreContext->GetHostName().toLower()) ||
(wantHost == gCoreContext->GetSetting("BackendServerIP")))
{
// handle request locally
LOG(VB_FILE, LOG_DEBUG, QString("Getting local info"));
StorageGroup sg(groupname, gCoreContext->GetHostName());
res = sg.GetFileInfo(filename);
if (res.count() == 0)
res << "EMPTY LIST";
}
else
{
// handle request on remote server
SocketHandler *remsock = NULL;
{
QReadLocker rlock(&m_fsLock);
if (m_fsMap.contains(wantHost))
{
remsock = m_fsMap[wantHost];
remsock->UpRef();
}
}
if (remsock)
{
res << "QUERY_SG_FILEQUERY" << wantHost << groupname << filename;
remsock->SendReceiveStringList(res);
remsock->DownRef();
}
else
{
res << "SLAVE UNREACHABLE: " << wantHost;
}
}
socket->SendStringList(res);
return true;
}
示例2: HandleAnnounce
bool BaseRequestHandler::HandleAnnounce(MythSocket *socket,
QStringList &commands, QStringList &slist)
{
if (commands.size() != 4)
return false;
bool blockShutdown;
if (commands[1] == "Playback")
blockShutdown = true;
else if (commands[1] == "Monitor")
blockShutdown = false;
else
return false;
QString hostname = commands[2];
int eventlevel = commands[3].toInt();
bool systemevents = ( (eventlevel == 1) || (eventlevel == 3));
bool normalevents = ( (eventlevel == 1) || (eventlevel == 2));
SocketHandler *handler = new SocketHandler(socket, m_parent, hostname);
socket->setAnnounce(slist);
handler->BlockShutdown(blockShutdown);
handler->AllowStandardEvents(normalevents);
handler->AllowSystemEvents(systemevents);
m_parent->AddSocketHandler(handler);
QStringList sl; sl << "OK";
handler->SendStringList(sl);
handler->DownRef();
handler = NULL;
LOG(VB_GENERAL, LOG_DEBUG, QString("MainServer::ANN %1")
.arg(commands[1]));
LOG(VB_GENERAL, LOG_NOTICE, QString("adding: %1 as a client (events: %2)")
.arg(commands[2]).arg(eventlevel));
SendMythSystemEvent(QString("CLIENT_CONNECTED HOSTNAME %1")
.arg(commands[2]));
return true;
}
示例3: connectionClosed
void MythSocketManager::connectionClosed(MythSocket *sock)
{
{
QReadLocker rlock(&m_handlerLock);
QMap<QString, SocketRequestHandler*>::const_iterator i;
for (i = m_handlerMap.constBegin(); i != m_handlerMap.constEnd(); ++i)
(*i)->connectionClosed(sock);
}
{
QWriteLocker wlock(&m_socketLock);
if (m_socketMap.contains(sock))
{
SocketHandler *handler = m_socketMap.take(sock);
handler->DownRef();
}
}
}
示例4: HandleGetFileList
bool FileServerHandler::HandleGetFileList(SocketHandler *socket,
QStringList &slist)
{
QStringList res;
bool fileNamesOnly = false;
if (slist.size() == 5)
fileNamesOnly = slist[4].toInt();
else if (slist.size() != 4)
{
LOG(VB_GENERAL, LOG_ERR, QString("Invalid Request. %1")
.arg(slist.join("[]:[]")));
res << "EMPTY LIST";
socket->SendStringList(res);
return true;
}
QString host = gCoreContext->GetHostName();
QString wantHost = slist[1];
QString groupname = slist[2];
QString path = slist[3];
LOG(VB_FILE, LOG_INFO,
QString("HandleSGGetFileList: group = %1 host = %2 "
"path = %3 wanthost = %4")
.arg(groupname).arg(host).arg(path).arg(wantHost));
if ((host.toLower() == wantHost.toLower()) ||
(gCoreContext->GetSetting("BackendServerIP") == wantHost))
{
StorageGroup sg(groupname, host);
LOG(VB_FILE, LOG_INFO, "Getting local info");
if (fileNamesOnly)
res = sg.GetFileList(path);
else
res = sg.GetFileInfoList(path);
if (res.count() == 0)
res << "EMPTY LIST";
}
else
{
// handle request on remote server
SocketHandler *remsock = NULL;
{
QReadLocker rlock(&m_fsLock);
if (m_fsMap.contains(wantHost))
{
remsock = m_fsMap[wantHost];
remsock->UpRef();
}
}
if (remsock)
{
LOG(VB_FILE, LOG_INFO, "Getting remote info");
res << "QUERY_SG_GETFILELIST" << wantHost << groupname << path
<< QString::number(fileNamesOnly);
remsock->SendReceiveStringList(res);
remsock->DownRef();
}
else
{
LOG(VB_FILE, LOG_ERR, QString("Failed to grab slave socket : %1 :")
.arg(wantHost));
res << "SLAVE UNREACHABLE: " << wantHost;
}
}
socket->SendStringList(res);
return true;
}