本文整理汇总了C++中message类的典型用法代码示例。如果您正苦于以下问题:C++ message类的具体用法?C++ message怎么用?C++ message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了message类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:ash-github,项目名称:netserver,代码行数:35,代码来源:netserver.cpp
示例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));
}
开发者ID:nobody,项目名称:magiclegoblimps,代码行数:29,代码来源:AdminClient.cpp
示例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;
};
开发者ID:ndyann,项目名称:Guider,代码行数:27,代码来源:GuiderToTMTC.cpp
示例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;
};
开发者ID:ndyann,项目名称:Guider,代码行数:35,代码来源:GuiderToTMTC.cpp
示例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);
};
开发者ID:ndyann,项目名称:Guider,代码行数:25,代码来源:GuiderToTMTC.cpp
示例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;
}
开发者ID:kamrann,项目名称:workbase,代码行数:32,代码来源:message.cpp
示例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);
}
开发者ID:ariosx,项目名称:actor-framework,代码行数:25,代码来源:matcher.hpp
示例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;
}
开发者ID:ndyann,项目名称:Guider,代码行数:60,代码来源:GuiderToTMTC.cpp
示例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;
};
开发者ID:ndyann,项目名称:Guider,代码行数:31,代码来源:GuiderToMPF.cpp
示例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();
}
开发者ID:4og,项目名称:schism,代码行数:32,代码来源:listener_ostream.cpp
示例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;
};
开发者ID:ndyann,项目名称:Guider,代码行数:34,代码来源:GuiderToMPF.cpp
示例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;
};
开发者ID:ndyann,项目名称:Guider,代码行数:28,代码来源:GuiderToTMTC.cpp
示例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;
}
开发者ID:Lukas-W,项目名称:lmms,代码行数:59,代码来源:RemotePlugin.cpp
示例14: receivemessage
void randommover::receivemessage(message msg)
{
if(msg.get("changeposition"))
{
position.setx(msg.get("x"));
position.sety(msg.get("y"));
}
}
开发者ID:Loddgrimner,项目名称:betelgeuse,代码行数:8,代码来源:randommover.cpp
示例15: receivemessage
void pointdraw::receivemessage(message msg)
{
if(msg.get("changeposition"))
{
x = msg.get("x");
y = msg.get("y");
}
}
开发者ID:Loddgrimner,项目名称:betelgeuse,代码行数:8,代码来源:pointdraw.cpp
示例16: ClientConnect
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());
}
开发者ID:dr520,项目名称:moon_net,代码行数:8,代码来源:GateModule.cpp
示例17: write
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));
}
开发者ID:zeusever,项目名称:lemonxx-lib,代码行数:8,代码来源:type_rw.hpp
示例18: throw
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);
}
}
开发者ID:EasyLinux,项目名称:Openchange,代码行数:57,代码来源:attachment.cpp
示例19: assert
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);
}
}
开发者ID:ZhHong,项目名称:moon_net,代码行数:10,代码来源:actor_manager.cpp
示例20: incoming_message
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());
}
开发者ID:FlibbleMr,项目名称:neoirc,代码行数:10,代码来源:dns.cpp
注:本文中的message类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论