本文整理汇总了C++中message::get_socket_id方法的典型用法代码示例。如果您正苦于以下问题:C++ message::get_socket_id方法的具体用法?C++ message::get_socket_id怎么用?C++ message::get_socket_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类message
的用法示例。
在下文中一共展示了message::get_socket_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: 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 模块
}
}
示例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: ActorData
void GateModule::ActorData(const message& msg)
{
UserContext ctx = get_userdata<UserContext>(msg);
if (ctx.receiver_echo_id != 0)
{
HandlerEchoMessage(ctx.receiver_echo_id, msg);
return;
}
user_id userid;
userid.set_account_id( account_id::create(ctx.accountid));
userid.set_player_id(player_id::create(ctx.playerid));
userid.set_socket_id(socket_id::create(msg.get_socket_id()));
if (DispatchMessages(userid,msg,ctx.sender_echo_id))
{
return;
}
}