本文整理汇总了C++中HTTPServer::SendEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ HTTPServer::SendEvent方法的具体用法?C++ HTTPServer::SendEvent怎么用?C++ HTTPServer::SendEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTPServer
的用法示例。
在下文中一共展示了HTTPServer::SendEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xprintf
void
SiteHandlerStream::HandleStream(EventStream* p_stream)
{
bool result = false;
// Use the event stream
testStream = p_stream;
HTTPServer* server = p_stream->m_site->GetHTTPServer();
// Report it
xprintf("NEW EVENT STREAM : %p\n", (void*)testStream);
for(int x = 1; x <= EventTests; ++x)
{
ServerEvent* eventx = new ServerEvent("message");
eventx->m_id = x;
eventx->m_data.Format("This is message number: %u\n",x);
result = server->SendEvent(p_stream,eventx);
// --- "---------------------------------------------- - ------
qprintf("Event stream OnMessage %d sent : %s\n", x, result ? "OK" : "ERROR");
if(result)
{
--totalChecks;
}
else
{
xerror();
}
// Waiting long time to see if the flush works and testing event streams
// with immediately reaction on the client
// Sleep(20000);
// Wait 1/10 of a second
Sleep(100);
}
xprintf("Sending other messages\n");
ServerEvent* ander = new ServerEvent("other");
ander->m_id = 1;
ander->m_data = "This is a complete different message in another set of stories.";
result = server->SendEvent(p_stream,ander);
// --- "---------------------------------------------- - ------
qprintf("Event stream 'other' message sent : %s\n", result ? "OK" : "ERROR");
if(result)
{
--totalChecks;
}
else
{
xerror();
}
xprintf("Sending an error message\n");
ServerEvent* err = new ServerEvent("error");
err->m_id = 0;
err->m_data = "This is a very serious bug report from your server! Heed attention to it!";
result = server->SendEvent(p_stream,err);
// --- "---------------------------------------------- - ------
qprintf("Event stream 'OnError' message sent : %s\n", result ? "OK" : "ERROR");
if(result)
{
--totalChecks;
}
else
{
xerror();
}
// Implicitly sending an OnClose
xprintf("Closing event stream\n");
server->CloseEventStream(p_stream);
// Check for closed stream
result = !server->HasEventStream(p_stream);
// --- "---------------------------------------------- - ------
qprintf("Event stream closed by server (OnClose sent) : %s\n", result ? "OK" : "ERROR");
if(result)
{
--totalChecks;
}
else
{
xerror();
}
}