예제 #1
0
	  virtual bool work(message& task)       // 在些完成实际任务.
	  {
		  session_ptr psession;
		  task.getsession(psession);
		  if (!psession)
			  return false;

		  google::protobuf::Message* msg;
		  message::headerPtr head = task.head();
		  size_t size = head->packsize - HEADER_LENGTH;
		  void* buf = (void*)((char*)head +  HEADER_LENGTH);

		  switch (head->type)
		  {
			case MSG_PACK_HEART:		// 处理心跳.
				{
					msg = new protocol::Heart;
					msg->ParseFromArray(buf, size);
				}
				break;

			case MSG_PACK_LOGON:		// 处理登陆.
				{
					msg = new protocol::Logon;
					msg->ParseFromArray(buf, size);
				}
				break;

			default:
				break;
		  }

		  delete msg;
		  return true;
	  }
예제 #2
0
void AdminClient::read_handler(const boost::system::error_code& error, std::size_t bytes) {
    std::cout << "Recieved " << bytes << " bytes.\n";

    // The extra parens around the first argument here are necessary 
    // to avoid g++ interpreting this as a function declaration
    //std::string s((std::istreambuf_iterator<char>(&read_buffer_)), std::istreambuf_iterator<char>());

    if (error == boost::asio::error::eof)
        close();
    else if (error == boost::asio::error::operation_aborted)
        return;
    else if (error){
        std::cout << "Throwing an error.\n";
        throw boost::system::system_error(error); // Some other error.
    }

    std::string s(read_message_.data(bytes));
    std::cout << "Built string.\n";

    read_message_.consume(bytes);
    std::cout << read_message_.buffer().size() << " bytes remaining in buffer.\n";

    std::cout << s << "-----------------------\n";

    boost::system::error_code err;
    boost::asio::async_read_until(sock_, read_message_.buffer(), '\n', 
        boost::bind(&AdminClient::read_handler, this, 
            boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
예제 #3
0
void GtoT_PointingErrors(float el, float ce){
  static message m;

  
  m.length = 16;
  m.body[0] = 0x55;
  _cnt = GtoT_Count();
  _pus = (unsigned short *) &m.body[1];
  *_pus = _cnt;  
  _pus = (unsigned short *) &m.body[3];
  *_pus = 9;  
  
  m.body[5] = 255;
  
  _pf = (float *) &m.body[6];
  *_pf = el;
  
  _pf = (float *) &m.body[10];
  *_pf = ce;
  
  m.body[14]=m.FindCRC();
  m.body[15] = 0xAA;
  
  SendToTMTC(m);
  //  WriteToLog("Sent out pointint errors!\0");  
  return;
};
예제 #4
0
void GtoT_ELCETCReply(unsigned char success)
{
static  char logentry[128];
static   char err;
static   message m;

  err = 0;

  if(success == 0 || success == 1){
    
    m.length = 9;
    m.body[0]=0x55;
    
    _cnt = GtoT_Count();
    _pus = (unsigned short *) &m.body[1];
    *_pus = _cnt;

    _pus = (unsigned short *) &m.body[3];
    *_pus = 2;

    _pus = (unsigned short *) &m.body[5];
    *_puc = 123;
    
    m.body[6] = success;
    
    m.body[7]=m.FindCRC();
    m.body[8] = 0xAA;
    
    SendToTMTC(m);

    sprintf(logentry,"GtoT,ELCETCReply,%d",success);
    WriteToLog(logentry);
  }; 
  return;
};
예제 #5
0
void GtoT_MessageRcvd(unsigned char msg){
  static message m;
  m.length = 9;
  
  m.body[0]=0x55;

    _cnt = GtoT_Count();
    _pus = (unsigned short *) &m.body[1];
    *_pus = _cnt;

    _pus = (unsigned short *) &m.body[3];
    *_pus = 2;

    m.body[5] = 254;
    
    m.body[6] = msg;
    
    m.body[7]=m.FindCRC();
    m.body[8] = 0xAA;
    
    SendToTMTC(m);

    //    sprintf(logentry,"GtoT,AutoCollimationTCReply,%d",success);
    //    WriteToLog(logentry);
}; 
예제 #6
0
	std::vector< char > encode_message(message const& msg)
	{
		YAML::Node encoding;

		auto cls = msg.get_class();
		encoding["class"] = cls;

		switch(cls)
		{
			case MessageClass::Peer2Peer:
			encoding["type"] = msg.get_type< MessageClass::Peer2Peer, Peer2PeerMsg >();
			break;

			case MessageClass::Peer2Client:
			encoding["type"] = msg.get_type< MessageClass::Peer2Client, Peer2ClientMsg >();
			break;

			case MessageClass::Client2Peer:
			encoding["type"] = msg.get_type< MessageClass::Client2Peer, Client2PeerMsg >();
			break;
		}

		encoding["content"] = msg.get_content().get();

		auto as_string = YAML::Dump(encoding);
		auto const msg_length = as_string.length();	// TODO: Check this is correct regardless of character encoding
		auto as_bytes = std::vector < char > {};
		as_bytes.resize(MessageSizeMarkerBytes + msg_length);
		*(size_t*)&as_bytes[0] = msg_length;
		std::copy(std::begin(as_string), std::end(as_string), as_bytes.begin() + MessageSizeMarkerBytes);
		return as_bytes;
	}
예제 #7
0
 bool operator()(const message& tup, pseudo_tuple<Us...>* out) const {
   auto& tarr = static_types_array<Ts...>::arr;
   if (sizeof...(Us) == 0) {
     // this pattern only has wildcards and thus always matches
     return true;
   }
   if (tup.size() < sizeof...(Us)) {
     return false;
   }
   if (out) {
     size_t pos = 0;
     size_t fallback_pos = 0;
     auto fpush = [&](const typename message::const_iterator& iter) {
       (*out)[pos++] = const_cast<void*>(iter.value());
     };
     auto fcommit = [&] { fallback_pos = pos; };
     auto frollback = [&] { pos = fallback_pos; };
     return (*this)(tup.begin(), tup.end(), tarr.begin(), tarr.end(), fpush,
                    fcommit, frollback);
   }
   auto no_push = [](const typename message::const_iterator&) { };
   auto nop = [] { };
   return (*this)(tup.begin(), tup.end(), tarr.begin(), tarr.end(), no_push,
                  nop, nop);
 }
예제 #8
0
void GtoT_CameraStatusTCReply(
			      unsigned short ROIX,
			      unsigned short ROIY,
			      unsigned short ROIdX,
			      unsigned short ROIdY,
			      unsigned char binning,
			      unsigned short expt
			      ){

static  char logentry[128];
static   message m;





  m.length = 19;

  m.body[0]=0x55;
  
  _cnt = GtoT_Count();
  _pus = (unsigned short *) &m.body[1];
  *_pus = _cnt;
  
  _pus = (unsigned short *) &m.body[3];
  *_pus = 12;
  
  _pus = (unsigned short *) &m.body[5];
  *_puc = 130;

  _pus = (unsigned short *) &m.body[6];
  *_pus = ROIX;

  _pus = (unsigned short *) &m.body[8];
  *_pus = ROIY;

  _pus = (unsigned short *) &m.body[10];
  *_pus = ROIdX;

  _pus = (unsigned short *) &m.body[12];
  *_pus = ROIdY;

  m.body[14] = binning;

  _pus = (unsigned short *) &m.body[15];
  *_pus = expt;

  m.body[17] = m.FindCRC();
  m.body[18] = 0xAA;  
  
  SendToTMTC(m);

  sprintf(logentry,"GtoT,CameraStatusTCReply,%d,%d,%d,%d,%d,%d",ROIX, ROIY,ROIdX, ROIdY, binning, expt);
  
  WriteToLog(logentry);

  

  return;
}
예제 #9
0
 char GtoM_SwitchingDTURequest(
				  ){
static unsigned short *pUS;
static int err;
static unsigned short    int cnt;   
static   message m;
static  char logentry[128];
   err = 0 ;

   m.length = 8;
   m.body[0]=0x55;
   cnt = GtoM_Count();
   pUS = (unsigned short *) &m.body[1];
   *pUS = cnt; 
   pUS = (unsigned short *) &m.body[3]; 
   *pUS = 1;
   
   m.body[5] = 4;
   
   m.body[6] = m.FindCRC();
   m.body[7] = 0xAA;
   
   if(SendToMPFNum(m)) return 2;

   sprintf(logentry,"GtoM,S,4,SwitchingDTURequest");
   
   WriteToLog(logentry);
   
   
   return 0;
 };
예제 #10
0
void
listener_ostream::notify(const message& msg)
{
    switch (msg.log_level().log_level()) {
    case ll_fatal:
    case ll_error:
        _ostream << util::bg_red << util::fg_yellow;
        break;
    case ll_warning:
        _ostream << util::bg_black << util::fg_red;
        break;
    case ll_info:
        _ostream << util::bg_black << util::fg_green;
        break;
    case ll_output:
        _ostream << util::bg_black << util::fg_dk_cyan;
        break;
    case ll_debug:
    case ll_trace:
        _ostream << util::bg_blue << util::fg_white;
        break;
    }
    // generate the message strings
    get_log_message(msg);
    _ostream << msg.postdec_decoration();
    _ostream << util::reset_color;
    _ostream << msg.postdec_message();

    //_ostream << get_log_message(msg);

    _ostream.flush();
}
예제 #11
0
 char GtoM_AutoCollimationTC(
				  ){
static unsigned short *pUS;

static int err;

   
static    message m;
static    char logentry[128];
   err=0;
static unsigned short int cnt;

   m.length = 8;
   m.body[0]=0x55;
   cnt = GtoM_Count();
   pUS = (unsigned short *) &m.body[1];
   *pUS = cnt; 
   pUS = (unsigned short *) &m.body[3]; 
   *pUS = 1;
   
   m.body[5] = 100;
   
   m.body[6] = m.FindCRC();
   m.body[7] = 0xAA;
   
   if(SendToMPFNum(m)) return 2;

   sprintf(logentry,"GtoM,S,100,AutoCollimationTC");
   
   WriteToLog(logentry);
   
   
   return 0;
 };
예제 #12
0
void GtoT_AutocollimationOffsets(float x, float y, float r){//251
  static message m;
  m.length = 20;
  m.body[0] = 0x55;
  _cnt = GtoT_Count();
  _pus = (unsigned short *) &m.body[1];
  *_pus = _cnt;  
  _pus = (unsigned short *) &m.body[3];
  *_pus = 13;  
  
  m.body[5] = 251;
  
  _pf = (float *) &m.body[6];
  *_pf = x;
  
  _pf = (float *) &m.body[10];
  *_pf = y;

  _pf=(float*) &m.body[14];
  *_pf = r;
  
  m.body[18]=m.FindCRC();
  m.body[19] = 0xAA;
  
  SendToTMTC(m);
  //  WriteToLog("Sent out pointint errors!\0");  
  return;
};
예제 #13
0
bool RemotePlugin::processMessage( const message & _m )
{
	lock();
	message reply_message( _m.id );
	bool reply = false;
	switch( _m.id )
	{
		case IdUndefined:
			unlock();
			return false;

		case IdInitDone:
			reply = true;
			break;

		case IdSampleRateInformation:
			reply = true;
			reply_message.addInt( Engine::mixer()->processingSampleRate() );
			break;

		case IdBufferSizeInformation:
			reply = true;
			reply_message.addInt( Engine::mixer()->framesPerPeriod() );
			break;

		case IdChangeInputCount:
			m_inputCount = _m.getInt( 0 );
			resizeSharedProcessingMemory();
			break;

		case IdChangeOutputCount:
			m_outputCount = _m.getInt( 0 );
			resizeSharedProcessingMemory();
			break;

		case IdChangeInputOutputCount:
			m_inputCount = _m.getInt( 0 );
			m_outputCount = _m.getInt( 1 );
			resizeSharedProcessingMemory();
			break;

		case IdDebugMessage:
			fprintf( stderr, "RemotePlugin::DebugMessage: %s",
						_m.getString( 0 ).c_str() );
			break;

		case IdProcessingDone:
		case IdQuit:
		default:
			break;
	}
	if( reply )
	{
		sendMessage( reply_message );
	}
	unlock();

	return true;
}
예제 #14
0
void randommover::receivemessage(message msg)
{
	if(msg.get("changeposition"))
	{
		position.setx(msg.get("x"));
		position.sety(msg.get("y"));
	}
}
예제 #15
0
void pointdraw::receivemessage(message msg)
{
	if(msg.get("changeposition"))
	{
		x = msg.get("x");
		y = msg.get("y");
	}
}
예제 #16
0
void GateModule::ClientConnect(const message& msg)
{
	buffer_reader buf(msg.data(), msg.size());

	std::string addr;
	buf >> addr;
	Log.trace("socket [socket:{0}] [address:{1}] connect", msg.get_socket_id().value,addr.data());
}
예제 #17
0
	inline void write(message & msg, uint64_t val)
	{
		byte_t type = uint64_type;

		msg.write((const byte_t*)&type,1);

		msg.write((const byte_t*)&val,sizeof(val));
	}
예제 #18
0
attachment::attachment(message& mapi_message, const uint32_t attach_num) throw(mapi_exception)
: object(mapi_message.get_session(), "attachment"), m_attach_num(attach_num), m_bin_data(NULL), m_data_size(0), m_filename("")
{
	if (OpenAttach(&mapi_message.data(), attach_num, &m_object) != MAPI_E_SUCCESS)
		throw mapi_exception(GetLastError(), "attachment::attachment : OpenAttach");

	property_container properties = get_property_container();
	properties << PR_ATTACH_FILENAME << PR_ATTACH_LONG_FILENAME << PR_ATTACH_SIZE << PR_ATTACH_DATA_BIN << PR_ATTACH_METHOD;
	properties.fetch();

	const char* filename = static_cast<const char*>(properties[PR_ATTACH_LONG_FILENAME]);
	if (!filename) {
		filename = static_cast<const char*>(properties[PR_ATTACH_FILENAME]);
	}

	if (filename)
		m_filename = filename;

	m_data_size = *(static_cast<const uint32_t*>(properties[PR_ATTACH_SIZE]));

	const Binary_r* attachment_data = static_cast<const Binary_r*>(properties[PR_ATTACH_DATA_BIN]);

	// Don't load PR_ATTACH_DATA_BIN if it's embedded in message.
	// NOTE: Use RopOpenEmbeddedMessage when it is implemented.
	const uint32_t attach_method = *static_cast<const uint32_t*>(properties[PR_ATTACH_METHOD]);
	if (attach_method != ATTACH_BY_VALUE)
		return;

	// Get Binary Data.
	if (attachment_data) {
		m_data_size = attachment_data->cb;
		m_bin_data = new uint8_t[m_data_size];
		memcpy(m_bin_data, attachment_data->lpb, attachment_data->cb);
	} else {
		mapi_object_t obj_stream;
		mapi_object_init(&obj_stream);
		if (OpenStream(&m_object, (enum MAPITAGS)PidTagAttachDataBinary, OpenStream_ReadOnly, &obj_stream) != MAPI_E_SUCCESS)
			throw mapi_exception(GetLastError(), "attachment::attachment : OpenStream");

		if (GetStreamSize(&obj_stream, &m_data_size) != MAPI_E_SUCCESS)
			throw mapi_exception(GetLastError(), "attachment::attachment : GetStreamSize");

		m_bin_data = new uint8_t[m_data_size];

		uint32_t pos = 0;
		uint16_t bytes_read = 0;
		do {
			if (ReadStream(&obj_stream, m_bin_data+pos, 1024, &bytes_read) != MAPI_E_SUCCESS)
				throw mapi_exception(GetLastError(), "attachment::attachment : ReadStream");

			pos += bytes_read;

		} while (bytes_read && pos < m_data_size);

		mapi_object_release(&obj_stream);
	}
}
예제 #19
0
	void actor_manager::broadcast_message(module_id sender,message& msg)
	{
		assert(msg.get_type() != EMessageType::Unknown);
		msg.set_sender(sender);
		msg.set_receiver(module_id::create(0));
		for (auto& w : _workers)
		{
			w->broadcast_message(msg);
		}
	}
예제 #20
0
파일: dns.cpp 프로젝트: FlibbleMr/neoirc
	void dns_requester::incoming_message(connection& aConnection, const message& aMessage)
	{
		if (aMessage.command() != message::NICK)
			return;
		user oldUser(aMessage.origin(), aConnection);
		user newUser(oldUser);
		if (!aMessage.parameters().empty())
			newUser.nick_name() = aMessage.parameters()[0];
		nick_change(oldUser.nick_name(), newUser.nick_name());
	}
예제 #21
0
파일: recv.hpp 프로젝트: BianJian/mmo
inline std::pair<aid_t, bool> recv_impl(
  gce::nonblocked, Recver& recver, message& msg, pattern& patt, recv_meta meta = recv_meta()
  )
{
  bool has_exit = check_exit(patt.match_list_);
  aid_t sender = recver.recv(msg, patt.match_list_, patt.recver_);
  if (meta.matched_ != 0)
  {
    *meta.matched_ = msg.get_type();
  }
  if (!has_exit && msg.get_type() == exit)
  {
    if (meta.guard_ != 0)
    {
      *meta.guard_ = boost::asio::error::make_error_code(boost::asio::error::shut_down);
      return std::make_pair(sender, false);
    }
    else
    {
      exit_code_t exc;
      std::string errmsg;
      msg >> exc >> errmsg;
      if (exc == exit_normal)
      {
        GCE_VERIFY(false)(exc)(msg)(patt)(sender)
          .msg("gce::normal_exception").except<normal_exception>();
      }
      else if (exc == exit_except)
      {
        GCE_VERIFY(false)(exc)(msg)(patt)(sender)
          .msg("gce::runtime_exception").except<runtime_exception>();
      }
      else if (exc == exit_remote)
      {
        GCE_VERIFY(false)(exc)(msg)(patt)(sender)
          .msg("gce::remote_exception").except<remote_exception>();
      }
      else if (exc == exit_already)
      {
        GCE_VERIFY(false)(exc)(msg)(patt)(sender)
          .msg("gce::already_exit_exception").except<already_exit_exception>();
      }
      else if (exc == exit_neterr)
      {
        GCE_VERIFY(false)(exc)(msg)(patt)(sender)
          .msg("gce::neterr_exception").except<neterr_exception>();
      }
      else
      {
        GCE_ASSERT(false)(exc)(errmsg);
      }
    }
  }
  return std::make_pair(sender, sender != aid_nil);
}
예제 #22
0
void GtoT_FrameBlobs(frameblob *fb){
  bloblist *pblob;
  unsigned short x[10],y[10];
  unsigned int flux[10];
  double cx, cy;
  unsigned char blobs;
  unsigned char currentblob;
  static message m;

  currentblob = 0;
  blobs = 0;

  pblob = fb->getblobs();
  m.length = 89;
  m.body[0] = 0x55;
  _cnt = GtoT_Count();
    _pus = (unsigned short *) &m.body[1];
  *_pus = _cnt;  
  _pus = (unsigned short *) &m.body[3];
  *_pus = 82;  
  
  m.body[5] = 250;
  
  static int i;
  for(i=0;i<10;i++){
    x[i] = 0;
    y[i] = 0;
  };

  while(pblob!=NULL && currentblob<10){
    x[currentblob]=(unsigned short) floor(pblob->getx()+0.5);
    y[currentblob]=(unsigned short) floor(pblob->gety()+0.5);
    flux[currentblob] = (unsigned int) pblob->getflux();
    pblob = pblob->getnextblob();
    currentblob++;
  };

  blobs = currentblob;
  m.body[6] = blobs;
  for(i=0;i<10;i++){
    _pus= (unsigned short *) &m.body[7+8*i];
    *_pus = x[i];
    _pus= (unsigned short *) &m.body[9+8*i];
    *_pus = y[i];
    _pui = (unsigned int *) &m.body[11+8*i];
    *_pui = flux[i];
  };
  m.body[87]=m.FindCRC();
  m.body[88] = 0xAA;

  SendToTMTC(m);
  

};
예제 #23
0
	void actor_manager::send_message(module_id sender, module_id receiver,message& msg)
	{
		assert(msg.get_type() != EMessageType::Unknown);
		msg.set_sender(sender);
		msg.set_receiver(receiver);
		uint8_t workerID = get_workerID(receiver);
		if (workerID < _workers.size())
		{
			_workers[workerID]->dispatch_message(msg);
		}
	}
예제 #24
0
파일: actor.cpp 프로젝트: ZhHong/moon_net
	void actor::send_message( module_id receiver,message& msg)
	{
		//if send self message , add to message queue directly.
		if (receiver == get_id())
		{
			msg.set_sender(get_id());
			msg.set_receiver(get_id());
			add_message(msg);
			return;
		}
		_Imp->mgr->send_message(get_id(), receiver, msg);
	}
const bool TCPStream::send(message& datumToSend, const unsigned int delayTime) {
	datumToSend.makeMessage();

	int iResult = ::send(socketDescriptor, datumToSend.getMessage().c_str(), datumToSend.getMessage().size() + 1, 0);
	if (iResult == SOCKET_ERROR) {
		throw ExecuteWinSocketFailed("Send Failed!", iResult);
		return false;
	}

	Sleep(delayTime);
	return true;
}
예제 #26
0
//客户端发来的数据
void GateModule::ClientData(const message& msg)
{
	if (msg.size() == 0)
		return;

	user_id id(account_id::create(0));
	id.set_socket_id(msg.get_socket_id());

	if (DispatchMessages(id,msg,0))
	{
		return;
	}
	
	auto pconn = m_Connections->find(msg.get_socket_id());
	if (pconn == nullptr)
	{
		Log.trace("非法数据!");
		return;
	}


	uint16_t msgID = *(uint16_t*)msg.data();
	if (msgID > (uint16_t)EMsgID::MSG_MUST_HAVE_PLAYERID)
	{
		if (pconn->getplayer_id() == player_id())
		{
			Log.trace("非法数据!");
			return;
		}
	}

	UserContext ctx;
	ctx.accountid = pconn->getaccount_id();
	ctx.playerid = pconn->getplayer_id();

	msg.set_userdata((uint8_t*)&ctx,sizeof(ctx));

	if (pconn->getscene_id() != 0)
	{
		//如果在玩家在场景模块中 则发送给场景模块
	}
	else
	{
		if (m_WorldModule == 0)
		{
			m_WorldModule = GetOtherModule("world");
			assert(m_WorldModule != 0);
		}

		//否则发送给 world 模块
	}
}
예제 #27
0
void dumbmover::receivemessage(message msg)
{
	if(msg.get("changeposition"))
	{
		position.setx(msg.get("x"));
		position.sety(msg.get("y"));
	}
	if(msg.get("changedelta"))
	{
		delta.setx(msg.get("deltax"));
		delta.sety(msg.get("deltay"));
	}
}
merged_tuple::cow_ptr merged_tuple::make(message x, message y) {
  data_type data{x.vals(), y.vals()};
  mapping_type mapping;
  auto s = x.size();
  for (size_t i = 0; i < s; ++i) {
    if (x.match_element<index_mapping>(i))
      mapping.emplace_back(1, x.get_as<index_mapping>(i).value - 1);
    else
      mapping.emplace_back(0, i);
  }
  return cow_ptr{make_counted<merged_tuple>(std::move(data),
                                            std::move(mapping))};
}
예제 #29
0
 char GtoM_TrackingRequest(
			   double ra,
			   double dec,
			   unsigned char config
			   ){
static unsigned short *pUS;
static  double *pd;
static int err;
static  unsigned short int cnt;   
static   message m;
static    char logentry[128];
   err = 0 ;

   if(config > 2) err++;
   
   if(err >0) return 1;

   m.length = 25; 

   m.body[0] = 0x55;
   cnt = GtoM_Count();
   pUS = (unsigned short *) &m.body[1];
   *pUS = cnt; 
   pUS = (unsigned short *) &m.body[3]; 
   *pUS = 18;
   
   m.body[5] = 5;
   
   pd = (double *) &m.body[6];
   *pd = ra;
   
   pd = (double *) &m.body[14];
   *pd = dec;

   m.body[22] = config;
   
   m.body[23] = m.FindCRC();
   

   m.body[24] = 0xAA;
   

   if(SendToMPFNum(m)) return 2;

   sprintf(logentry,"GtoM:TrackingRequest:%.5f,%.5f,%d",ra,dec,config);
   
   WriteToLog(logentry);

   
   return 0;
 };
예제 #30
0
    inline std::string serialize_to_json(const message& m)
    {
        std::ostringstream result;

        result << "{ ";

        result
            << format::quote << "error" << ':' << "false" << ','
            << format::quote << "data" << ':';

        result << "{ ";

        result
            << format::quote << "timestamp" << ':' << format::quote << format::timestamp(m.timestamp()) << ','
            << format::quote << "id" << ':' << format::quote << m.id() << ','
            << format::quote << "type" << ':' << format::quote << m.type();

        switch (m.type())
        {
            case message::HEARTBEAT:
                {
                    result << ','
                        << format::quote << "heartbeat" << ':' << m.heartbeat();
                }
                break;

            case message::STATUS:
                {
                    result << ','
                        << format::quote << "status" << ':' << format::quote << "not implemented";
                }
                break;

            case message::USER:
                {
                    result << ','
                        << format::quote << "user" << ':' << format::quote << "not implemented";
                }
                break;

            default:
                break;
        }

        result << " }";

        result << " }";

        return result.str();
    }