本文整理汇总了C++中WorkItem::getStream方法的典型用法代码示例。如果您正苦于以下问题:C++ WorkItem::getStream方法的具体用法?C++ WorkItem::getStream怎么用?C++ WorkItem::getStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorkItem
的用法示例。
在下文中一共展示了WorkItem::getStream方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void* run()
{
// Remove 1 item at a time and process it. Blocks if no items are
// available to process.
for (int i = 0;; i++)
{
//qDebug("thread %lu, loop %d - waiting for item...", (long unsigned int)self(), i);
WorkItem* item = m_queue.remove();
//qDebug("thread %lu, loop %d - got one item", (long unsigned int)self(), i);
TCPStream* stream = item->getStream();
// Echo messages back the client until the connection is
// closed
char input[256];
for (int i = 0; i < 255; i++)
{
input[i] = '\0';
}
string output;
int len;
while ((len = stream->receive(input, sizeof(input)-1)) > 0 )
{
output = "OK";
stream->send(output.c_str(), (sizeof(output.c_str())-1));
//qDebug("thread %lu, echoed '%s' back to the client", (long unsigned int)self(), input);
std::string cmd(input);
executeCommand(cmd);
}
delete item;
}
// Should never get here
return NULL;
}
示例2: run
void* run()
{
// Remove 1 item at a time and process it. Blocks if no items are
// available to process.
for (int i = 0;; i++)
{
//qDebug("thread %lu, loop %d - waiting for item...", (long unsigned int)self(), i);
WorkItem* item = m_queue.remove();
//qDebug("thread %lu, loop %d - got one item", (long unsigned int)self(), i);
TCPStream* stream = item->getStream();
// Echo messages back the client until the connection is
// closed
char input[10256];
for (int i = 0; i < 10255; i++)
{
input[i] = '\0';
}
string output;
int len;
while ((len = stream->receive(input, sizeof(input)-1)) > 0 )
{
output = "OK";
stream->send(output.c_str(), (sizeof(output.c_str())-1));
//qDebug("thread %lu, echoed '%s' back to the client", (long unsigned int)self(), input);
//taskPrefix - Remote Task Manager Message, HOP task
char taskPrefix[5];
strncpy(taskPrefix, input, 4);
taskPrefix[4] = '\0';
if (strcmp(taskPrefix, "RTMM") == 0)
{
std::string rtmm(input);
qDebug("%s", rtmm.c_str());
TaskManager::getInstance()->addUpdateRTMM(rtmm);
continue;
}
else if (strcmp(taskPrefix, "HOP_") == 0)
{
std::string hoptaskmsg(input);
qDebug("%s", hoptaskmsg.c_str());
TaskManager::getInstance()->sendScript(hoptaskmsg.substr(4));
continue;
}
else
{
std::string script(input);
if (script.length() > 0)
{
executeScript(script);
}
}
}
delete item;
}
// Should never get here
return NULL;
}