本文整理汇总了C++中PacketPtr::GetEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketPtr::GetEvent方法的具体用法?C++ PacketPtr::GetEvent怎么用?C++ PacketPtr::GetEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketPtr
的用法示例。
在下文中一共展示了PacketPtr::GetEvent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DispatchGateServer
bool CGameServer::DispatchGateServer(const PacketPtr& PktPtr, KeyRef krSocket)
{
bool bRet = false;
switch (PktPtr->GetEvent()) {
case PAK_EVENT_LINK:
{
bRet = OnServerLink(static_cast<CPAKLink*>(PktPtr.Get()), krSocket);
}
break;
case PAK_EVENT_UPDATE:
{
bRet = OnServerUpdate(static_cast<CPAKUpdate*>(PktPtr.Get()), krSocket);
}
break;
case PAK_EVENT_UNLINK:
{
bRet = OnServerUnlink(PktPtr.Get(), krSocket);
}
break;
case PAK_EVENT_GAME_ID:
{
CPAKGameIdAck GameIdAck;
GameIdAck.SetId((Int)m_ServerInfo.usId);
GameIdAck.AdjustSize();
m_NetworkPtr->Send(krSocket, GameIdAck);
}
break;
default:
{
LOGV_WARN(m_FileLog, TF("[游戏服务器]%p无法识别的网关服务器信令包数据[event=%d]"), krSocket, PktPtr->GetEvent());
}
}
return bRet;
}
示例2: DispatchGameDBServer
bool CGameServer::DispatchGameDBServer(const PacketPtr& PktPtr, KeyRef krSocket)
{
switch (PktPtr->GetEvent()) {
case PAK_EVENT_LINKACK:
{
m_bGameDBLinked = true;
NET_ADDR NetAddr;
m_NetworkPtr->GetAddr(krSocket, NetAddr, false);
m_pUIHandler->OnHandle(PAK_EVENT_LINK, reinterpret_cast<uintptr_t>(&NetAddr), DATA_INDEX_GAMEDB);
LOG_INFO(m_FileLog, TF("[游戏服务器]收到游戏DB服务器注册回复包"));
}
break;
case PAK_EVENT_UPDATEACK:
{
DEV_INFO(TF("[游戏服务器]收到游戏DB服务器更新回复包"));
}
break;
case PAK_EVENT_UNLINKACK:
{
m_bGameDBLinked = false;
LOG_INFO(m_FileLog, TF("[游戏服务器]收到游戏DB服务器注销回复包"));
}
break;
case PAK_EVENT_LIVEACK:
{
}
break;
default:
{
LOGV_WARN(m_FileLog, TF("[游戏服务器]%p无法识别的游戏DB服务器信令包数据[event=%d]"), krSocket, PktPtr->GetEvent());
}
}
return true;
}
示例3: DispatchZoneServer
bool CGameServer::DispatchZoneServer(const PacketPtr& PktPtr, KeyRef krSocket)
{
bool bRet = false;
switch (PktPtr->GetEvent()) {
case PAK_EVENT_LINK:
{
bRet = OnServerLink(static_cast<CPAKLink*>(PktPtr.Get()), krSocket);
}
break;
case PAK_EVENT_UPDATE:
{
bRet = OnServerUpdate(static_cast<CPAKUpdate*>(PktPtr.Get()), krSocket);
}
break;
case PAK_EVENT_UNLINK:
{
bRet = OnServerUnlink(PktPtr.Get(), krSocket);
}
break;
default:
{
LOGV_WARN(m_FileLog, TF("[游戏服务器]%p无法识别的地图服务器信令包数据[event=%d]"), krSocket, PktPtr->GetEvent());
}
}
return bRet;
}
示例4: OnUdpDispatch
//--------------------------------------
bool CGameServer::OnUdpDispatch(const PacketPtr& PktPtr, PUDP_PARAM pUdp)
{
// PUDP_PARAM->pCache == nullptr, 上层可以保存从底层申请的缓存数据
// PUDP_PARAM->pCache, PUDP_PARAM->index是底层申请的缓存数据的起始地址和索引号
// 如果上层保存缓存, 设置PUDP_PARAM->pData为nullptr通知网络底层
// 释放缓存使用MObject::sMCFree(index, pCache)
assert(PktPtr->GetEvent() == PAK_EVENT_LOGIN_SELECT_GAME);
CPAKLoginSelectGame* pSelect = static_cast<CPAKLoginSelectGame*>(PktPtr.Get());
if (SelectGame(pSelect) == false) {
pSelect->SetAck(LOGIN_ERROR_NONE_GATE);
m_NetworkPtr->SendTo(pUdp->krSocket, *pSelect, pUdp->NetAddr);
LOG_INFO(m_FileLog, TF("[游戏服务器]游戏服务器收到客户端选择游戏服务器请求, 但是没有网关服务器"));
}
return true;
}
示例5: OnTcpDispatch
//--------------------------------------
bool CGameServer::OnTcpDispatch(const PacketPtr& PktPtr, PTCP_PARAM pTcp)
{
// PTCP_PARAM->pCache == nullptr, 上层可以保存从底层申请的缓存数据
// PTCP_PARAM->pCache, PTCP_PARAM->index是底层申请的缓存数据的起始地址和索引号
// 如果上层保存缓存, 设置PTCP_PARAM->pData为nullptr通知网络底层
// 释放缓存使用MObject::sMCFree(index, pCache)
bool bRet = false;
if (PktPtr->GetEvent() != PAK_EVENT_LIVE) {
switch (PktPtr->GetType()) {
case PAK_TYPE_GATE:
{
bRet = DispatchGateServer(PktPtr, pTcp->krSocket);
}
break;
case PAK_TYPE_ZONE:
{
bRet = DispatchZoneServer(PktPtr, pTcp->krSocket);
}
break;
case PAK_TYPE_GAMEDB:
{
bRet = DispatchGameDBServer(PktPtr, pTcp->krSocket);
}
break;
case PAK_TYPE_CENTER:
{
bRet = DispatchCenterServer(PktPtr, pTcp->krSocket);
}
break;
default:
{
LOGV_WARN(m_FileLog, TF("[游戏服务器]%p信令包服务器类型[%d]不正确"), pTcp->krSocket, PktPtr->GetType());
bRet = false;
}
}
}
else {
CPAKSimple<PAK_EVENT_LIVEACK, PAK_TYPE_GAME> LiveAck;
LiveAck.AdjustSize();
bRet = m_NetworkPtr->Send(pTcp->krSocket, LiveAck);
}
return bRet;
}