本文整理汇总了C++中SocketHandler::AllowStandardEvents方法的典型用法代码示例。如果您正苦于以下问题:C++ SocketHandler::AllowStandardEvents方法的具体用法?C++ SocketHandler::AllowStandardEvents怎么用?C++ SocketHandler::AllowStandardEvents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SocketHandler
的用法示例。
在下文中一共展示了SocketHandler::AllowStandardEvents方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoConnectToMaster
bool OutboundRequestHandler::DoConnectToMaster(void)
{
if (m_socket)
m_socket->DecrRef();
m_socket = new MythSocket(-1, m_parent);
QString server = gCoreContext->GetMasterServerIP();
QString hostname = gCoreContext->GetMasterHostName();
int port = gCoreContext->GetMasterServerPort();
if (!m_socket->ConnectToHost(server, port))
{
LOG(VB_GENERAL, LOG_ERR, "Failed to connect to master backend.");
m_socket->DecrRef();
m_socket = NULL;
return false;
}
#ifndef IGNORE_PROTO_VER_MISMATCH
if (!m_socket->Validate())
{
LOG(VB_GENERAL, LOG_NOTICE, "Unable to confirm protocol version with backend.");
m_socket->DecrRef();
m_socket = NULL;
return false;
}
#endif
if (!AnnounceSocket())
{
LOG(VB_GENERAL, LOG_NOTICE, "Announcement to upstream master backend failed.");
m_socket->DecrRef();
m_socket = NULL;
return false;
}
SocketHandler *handler = new SocketHandler(m_socket, m_parent, hostname);
handler->BlockShutdown(true);
handler->AllowStandardEvents(true);
handler->AllowSystemEvents(true);
m_parent->AddSocketHandler(handler); // register socket for reception of events
handler->DecrRef(); // drop local instance in counter
handler = NULL;
LOG(VB_GENERAL, LOG_NOTICE, "Connected to master backend.");
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: HandleAnnounce
bool FileServerHandler::HandleAnnounce(MythSocket *socket,
QStringList &commands, QStringList &slist)
{
if (commands[1] == "FileServer")
{
if (slist.size() >= 3)
{
SocketHandler *handler =
new SocketHandler(socket, m_parent, commands[2]);
handler->BlockShutdown(true);
handler->AllowStandardEvents(true);
handler->AllowSystemEvents(true);
QWriteLocker wlock(&m_fsLock);
m_fsMap.insert(commands[2], handler);
m_parent->AddSocketHandler(handler);
slist.clear();
slist << "OK";
handler->SendStringList(slist);
return true;
}
return false;
}
if (commands[1] != "FileTransfer")
return false;
if (slist.size() < 3)
return false;
if ((commands.size() < 3) || (commands.size() > 6))
return false;
FileTransfer *ft = NULL;
QString hostname = "";
QString filename = "";
bool writemode = false;
bool usereadahead = true;
int timeout_ms = 2000;
switch (commands.size())
{
case 6:
timeout_ms = commands[5].toInt();
case 5:
usereadahead = commands[4].toInt();
case 4:
writemode = commands[3].toInt();
default:
hostname = commands[2];
}
QStringList::const_iterator it = slist.begin();
QUrl qurl = *(++it);
QString wantgroup = *(++it);
QStringList checkfiles;
while (++it != slist.end())
checkfiles += *(it);
slist.clear();
LOG(VB_GENERAL, LOG_DEBUG, "FileServerHandler::HandleAnnounce");
LOG(VB_GENERAL, LOG_INFO, QString("adding: %1 as remote file transfer")
.arg(hostname));
if (writemode)
{
if (wantgroup.isEmpty())
wantgroup = "Default";
StorageGroup sgroup(wantgroup, gCoreContext->GetHostName(), false);
QString dir = sgroup.FindNextDirMostFree();
if (dir.isEmpty())
{
LOG(VB_GENERAL, LOG_ERR, "Unable to determine directory "
"to write to in FileTransfer write command");
slist << "ERROR" << "filetransfer_directory_not_found";
socket->writeStringList(slist);
return true;
}
QString basename = qurl.path();
if (basename.isEmpty())
{
LOG(VB_GENERAL, LOG_ERR, QString("FileTransfer write "
"filename is empty in url '%1'.")
.arg(qurl.toString()));
slist << "ERROR" << "filetransfer_filename_empty";
socket->writeStringList(slist);
return true;
}
if ((basename.contains("/../")) ||
(basename.startsWith("../")))
{
LOG(VB_GENERAL, LOG_ERR, QString("FileTransfer write "
//.........这里部分代码省略.........