本文整理汇总了C++中message类的典型用法代码示例。如果您正苦于以下问题:C++ message类的具体用法?C++ message怎么用?C++ message使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了message类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: work
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: close
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: GtoT_PointingErrors
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: GtoT_ELCETCReply
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: GtoT_MessageRcvd
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: encode_message
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: operator
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: GtoT_CameraStatusTCReply
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: GtoM_SwitchingDTURequest
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: switch
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: GtoM_AutoCollimationTC
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: GtoT_AutocollimationOffsets
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: lock
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: receivemessage
void randommover::receivemessage(message msg)
{
if(msg.get("changeposition"))
{
position.setx(msg.get("x"));
position.sety(msg.get("y"));
}
}
示例15: receivemessage
void pointdraw::receivemessage(message msg)
{
if(msg.get("changeposition"))
{
x = msg.get("x");
y = msg.get("y");
}
}