当前位置: 首页>>代码示例>>C++>>正文


C++ HTTPServer::HasEventStream方法代码示例

本文整理汇总了C++中HTTPServer::HasEventStream方法的典型用法代码示例。如果您正苦于以下问题:C++ HTTPServer::HasEventStream方法的具体用法?C++ HTTPServer::HasEventStream怎么用?C++ HTTPServer::HasEventStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTTPServer的用法示例。

在下文中一共展示了HTTPServer::HasEventStream方法的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(); 
  }
}
开发者ID:edwig,项目名称:Marlin,代码行数:87,代码来源:TestEvents.cpp



注:本文中的HTTPServer::HasEventStream方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。