本文整理汇总了C++中message::size方法的典型用法代码示例。如果您正苦于以下问题:C++ message::size方法的具体用法?C++ message::size怎么用?C++ message::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类message
的用法示例。
在下文中一共展示了message::size方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: ClientClose
void GateModule::ClientClose(const message& msg)
{
buffer_reader buf(msg.data(), msg.size());
std::string addr;
buf >> addr;
Log.trace("1.client close [socketid:{0}] [address:{1}] begin.", msg.get_socket_id().value, addr.data());
auto pconn = m_Connections->find(msg.get_socket_id());
if (pconn == nullptr)
{
Log.trace("!!client close failed can not find conn [socketid:{0}].", msg.get_socket_id().value);
return;
}
auto accountID = pconn->getaccount_id();
auto playerID = pconn->getplayer_id();
Log.trace("3.client close [socketid:{0}] [address:{1}] find account data[accountid:{2}] success[playerid:{3}].", msg.get_socket_id().value, addr.data(), accountID.value,playerID.value);
OnClientClose(accountID, playerID);
if (m_Connections->remove(msg.get_socket_id()))
{
Log.trace("client close [socketid:{0}] [address:{1}] accountID[{2}] playerID[{3}] end.", msg.get_socket_id().value, addr.data(), accountID.value, playerID.value);
}
else
{
assert(0);
}
}
示例3: 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());
}
示例4: ClientData
//客户端发来的数据
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 模块
}
}
示例5: make
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))};
}
示例6: DispatchMessages
bool ModuleBases::DispatchMessages(const user_id & userid, const message & msg, uint64_t sender_echo_id)
{
buffer_reader br(msg.data(), msg.size());
uint16_t msgID = 0;
br >> msgID;
if (msgID == uint16_t(EMsgID::MSG_S2S_ClientClose))
{
account_id accountID;
player_id playerID;
br >> accountID.value;
br >> playerID.value;
OnClientClose(accountID, playerID);
return true;
}
示例7: invoke
match_case::result invoke(optional<message>& res, message& msg) override {
intermediate_tuple it;
detail::meta_elements<pattern> ms;
// check if try_match() reports success
if (!detail::try_match(msg, ms.arr.data(), ms.arr.size(), it.data)) {
return match_case::no_match;
}
// detach msg before invoking m_fun if needed
if (is_manipulator) {
msg.force_detach();
// update pointers in our intermediate tuple
for (size_t i = 0; i < msg.size(); ++i) {
// msg is guaranteed to be detached, hence we don't need to
// check this condition over and over again via mutable_at
it[i] = const_cast<void*>(msg.at(i));
}
}
lfinvoker<std::is_same<result_type, void>::value, F> fun{m_fun};
detail::optional_message_visitor omv;
auto funres = apply_args(fun, detail::get_indices(it), it);
res = omv(funres);
return match_case::match;
}