本文整理汇总了C++中message::get_type方法的典型用法代码示例。如果您正苦于以下问题:C++ message::get_type方法的具体用法?C++ message::get_type怎么用?C++ message::get_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类message
的用法示例。
在下文中一共展示了message::get_type方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: make_pair
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);
}
示例2: handle_message
void GateModule::handle_message(const message& msg)
{
switch (msg.get_type())
{
case EMessageType::SocketConnect:
{
ClientConnect(msg);
break;
}
case EMessageType::SocketData:
{
ClientData(msg);
break;
}
case EMessageType::SocketClose:
{
ClientClose(msg);
break;
}
case EMessageType::ActorData:
{
ActorData(msg);
break;
}
case EMessageType::ToClient:
{
ToClientData(msg);
break;
}
}
}
示例3: receive
void server::receive(QHostAddress const & ip, quint16 port, message const & msg)
{
switch (msg.get_type()) {
case message_type::client_server_request: {
// TODO: extract file size from message and pass to workers manager.
qDebug() << "Server: new client arrived.";
auto workers_ip_ports = workers_manager_.get_workers();
auto response = create_message<ip_port_array_message>(
message_type::server_client_response, workers_ip_ports);
auto sock = find_socket(ip, port);
qDebug() << "Server: sending client" << workers_ip_ports.size() << "workers.";
sock->send(*response);
break;
}
case message_type::worker_server_connect: {
auto m = static_cast<number_message const &>(msg);
auto sock = find_socket(ip, port);
worker_ids_[sock] = workers_manager_.add_new_worker(ip, m.number());
qDebug() << "Server: new worker arrived.";
break;
}
case message_type::worker_server_state_changed: {
quint32 const load_factor = static_cast<number_message const &>(msg).number();
auto sock = find_socket(ip, port);
auto it = worker_ids_.find(sock);
if (worker_ids_.end() != it)
workers_manager_.update_worker_load_factor(it.value(), load_factor);
else
qDebug() << "Server: trying to set load factor to unknown worker. Do nothing.";
break;
}
default:
qDebug() << "Server: unknown message type. Dropping message";
}
}
示例4: broadcast_message
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);
}
}
示例5: send_message
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);
}
}
示例6: recv
inline aid_t recv(Recver& recver, message& msg, match& mach)
{
bool add_exit = check_exit(mach.match_list_);
if (add_exit)
{
mach.match_list_.push_back(exit);
}
aid_t sender = recver.recv(msg, mach);
if (add_exit && msg.get_type() == exit)
{
exit_code_t exc;
std::string errmsg;
msg >> exc >> errmsg;
throw std::runtime_error(errmsg);
}
示例7: add_match_msg
///------------------------------------------------------------------------------
void mailbox::add_match_msg(recv_t const& rcv, aid_t sender, message const& msg)
{
recv_itr itr = recv_que_.insert(recv_que_.end(), std::make_pair(rcv, msg));
match_t type = msg.get_type();
match_itr mtr;
match_queue_t* match_que = 0;
if (type >= 0 && type < (match_t)cache_match_list_.size())
{
match_que = &cache_match_list_[type];
}
else
{
std::pair<match_queue_list_t::iterator, bool> pr =
match_queue_list_.insert(std::make_pair(type, dummy2_));
match_que = &pr.first->second;
}
mtr = match_que->insert(match_que->end(), itr);
if (sender && type == exit)
{
if (sender.svc_)
{
std::pair<aid_t, match_itr> p = std::make_pair(sender, mtr);
std::pair<svc_exit_list_t::iterator, bool> pr =
svc_exit_list_.insert(std::make_pair(sender.svc_, p));
if (!pr.second)
{
recv_que_.erase(*pr.first->second.second);
match_que->erase(pr.first->second.second);
pr.first->second = p;
}
}
else
{
std::pair<exit_list_t::iterator, bool> pr =
exit_list_.insert(std::make_pair(sender, mtr));
if (!pr.second)
{
recv_que_.erase(*pr.first->second);
match_que->erase(pr.first->second);
pr.first->second = mtr;
}
}
}
}
示例8:
void
make_frames(const message &msg, OutputIterator out)
{
const channel ch = msg.get_channel();
switch (msg.get_type()) {
case MSG:
{
msg_frame MSG;
MSG.channel = ch.get_number();
MSG.message = ch.get_message_number();
MSG.more = false;
MSG.sequence = ch.get_sequence_number();
MSG.payload = msg.get_payload();
*out++ = MSG;
}
break;
case RPY:
{
rpy_frame RPY;
RPY.channel = ch.get_number();
RPY.message = ch.get_message_number();
RPY.more = false;
RPY.sequence = ch.get_sequence_number();
RPY.payload = msg.get_payload();
*out++ = RPY;
}
break;
case ANS:
{
ans_frame ANS;
ANS.channel = ch.get_number();
ANS.message = ch.get_message_number();
ANS.more = false;
ANS.sequence = ch.get_sequence_number();
ANS.payload = msg.get_payload();
ANS.answer = ch.get_answer_number();
*out++ = ANS;
}
break;
case ERR:
{
err_frame ERR;
ERR.channel = ch.get_number();
ERR.message = ch.get_message_number();
ERR.more = false;
ERR.sequence = ch.get_sequence_number();
ERR.payload = msg.get_payload();
*out++ = ERR;
}
break;
case NUL:
{
nul_frame NUL;
NUL.channel = ch.get_number();
NUL.message = ch.get_message_number();
NUL.more = false;
NUL.sequence = ch.get_sequence_number();
NUL.payload = msg.get_payload();
*out++ = NUL;
}
break;
case SEQ:
default:
std::cerr << "The message has an invalid frame type.\n";
assert(false);
/// \todo throw ?
}
}