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


C++ MessagePtr::body方法代码示例

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


在下文中一共展示了MessagePtr::body方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: send_all

	void send_all(const T& value) {
		MessagePtr msg =  std::make_shared<Message>(sizeof(T));

		msg->set_body_length(sizeof(T));
		std::memcpy(msg->body(), &value, sizeof(T));
		msg->encode_header();
		send_all(msg);	
	}
开发者ID:bysreg,项目名称:dracuda,代码行数:8,代码来源:master.hpp

示例2: send

	void send(int conn_idx, const T& value) {
		// hack

		// MessagePtr msg =  std::make_shared<Message>(sizeof(T));
		MessagePtr msg = scene_write_msg;

		msg->set_body_length(sizeof(T));
		std::memcpy(msg->body(), &value, sizeof(T));
		msg->encode_header();
		send(conn_idx, msg);			
	}
开发者ID:bysreg,项目名称:dracuda,代码行数:11,代码来源:master.hpp

示例3: write

void Client::write(MessagePtr msg)
{
  if (!mRunning)
    return;

  // encodes message before sending
  msg->encode();
  
  // append the message
  boost::lock_guard<boost::mutex> lock(mWMutex);
  mWriteQ.push_back(msg);
  boost::lock_guard<boost::mutex> slock(mSMutex);
  mSent.push_back(std::string(msg->body()));

  // notify of new message
  mWCond.notify_one();
}
开发者ID:nikchi,项目名称:ChatTxt,代码行数:17,代码来源:Client.cpp

示例4: onReadBody

void Client::onReadBody(MessagePtr msg, const error_code& error)
{
  // make sure everything was successful
  if (!error && msg->decode())
    {
      // list of found messages
      bool found = false;
      boost::unique_lock<boost::mutex> slock(mSMutex);
      for (auto iter = mSent.begin(); iter != mSent.end() && !found; ++iter)
	{
	  if (!strcmp(iter->c_str(), msg->body()))
	    {
	      found = true;
	      mSent.erase(iter);
	    }
	}
            
      // prints the body
      if (!found)
		{
		printf("%s\n", msg->body());
      	if(0==strncmp(msg->body(),"/banksy",7))
			{
					printf("%s\n", "                       .s$$$Ss.");
					printf("%s\n", "            .8,         $$$. _. .              ..sS$$$$$'  ...,.;");
					printf("%s\n", "o.   ,@..  88        =.$'$'  '          ..sS$$$$$$$$$$$$s. _;''");
					printf("%s\n", "  @@@[email protected]@@. .88.   `  ` ""l. .sS$$.._.sS$$$$$$$$$$$$S'''");
					printf("%s\n", "   [email protected]@@[email protected]@.8888o.         .s$$$$$$$$$$$$$$$$$$$$$'");
					printf("%s\n", "     .:`@@@@33333.       .>$$$$$$$$$$$$$$$$$$$$'");
					printf("%s\n", "     .: `@@@@333'       ..>$$$$$$$$$$$$$$$$$$$'");
					printf("%s\n", "      :  `@@333.     `.,   s$$$$$$$$$$$$$$$$$'");
					printf("%s\n", "      :   `@33       $$ S.s$$$$$$$$$$$$$$$$$'");
					printf("%s\n", "      .S   `Y      ..`  ,'$' `$$$$$$$$$$$$$$");
					printf("%s\n", "      $s  .       ..S$s,    . .`$$$$$$$$$$$$.");
					printf("%s\n", "      $s .,      ,s ,$$$$,,sS$s.$$$$$$$$$$$$$.");
					printf("%s\n", "      / /$$SsS.s. ..s$$$$$$$$$$$$$$$$$$$$$$$$$.");
					printf("%s\n", "     /`.`$$$$$dN.ssS$$'`$$$$$$$$$$$$$$$$$$$$$$$.");
					printf("%s\n", "    /     `$$$$$$$$$'    `$$$$$$$$$$$$$$$$$$$$$$.");
					printf("%s\n", "   /  |     `S$$S$'       `$$$$$$$$$$$$$$$$$$$$$$.");
					printf("%s\n", "  / /                      $$$$$$$$$$$$$$$$$$$$$.");
					printf("%s\n", "                           `$$$$$$$$$$$$$$$$$$$$$s.");
					printf("%s\n", "                            $$$''        .?T$$$$$$$");
					printf("%s\n", "                           .$'        ...      ?$$# ");
					printf("%s\n", "                           !       -=S$$$$$s");
					printf("%s\n", "                         .!       -=s$$'  `$=-_      :");
					printf("%s\n", "                        ,        .$$$'     `$,       .|");
					printf("%s\n", "                       ,       .$$$'          .        ,");
					printf("%s\n", "                      ,     ..$$$'");
					printf("%s\n", "                          .s$$$'                 `s     .");
					printf("%s\n", "                   .   .s$$$$'                    $s. ..$s");
					printf("%s\n", "                  .  .s$$$$'                      `$s=s$$$");
					printf("%s\n", "                    .$$$$'                         ,    $$s");
			}
		}
      // start listening for the next message
      listen();
    }
  else // error
    {
      printf("Error reading body\n");
      kill();
    }
}
开发者ID:nikchi,项目名称:ChatTxt,代码行数:63,代码来源:Client.cpp


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