Files
mir_server/server/DBServer/DBSessionClient.cpp
aixianling 5c9f1dae4a init
2025-01-09 17:45:40 +08:00

68 lines
1.8 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "StdAfx.h"
CDBSessionClient::CDBSessionClient(CDBServer *lpDBServer)
{
m_pDBServer = lpDBServer;
}
CDBSessionClient::~CDBSessionClient()
{
}
SERVERTYPE CDBSessionClient::getLocalServerType()
{
return DBServer;
}
int CDBSessionClient::getLocalServerIndex()
{
return m_pDBServer->getServerIndex();
}
LPCSTR CDBSessionClient::getLocalServerName()
{
return m_pDBServer->getServerName();
}
CCustomGlobalSession* CDBSessionClient::CreateSession()
{
return Inherited::CreateSession();
}
VOID CDBSessionClient::DestroySession(CCustomGlobalSession* pSession)
{
Inherited::DestroySession(pSession);
}
VOID CDBSessionClient::OnOpenSession(CCustomGlobalSession* pSession, BOOL boIsNewSession)
{
//收到打开session的包的时候向session服务器发一个包回复一下session依据这个回复告诉客户端登陆
//通过这个确认的流程保证登陆服务器的时候session的数据是到位的
//只有自己的数据服务器才会回复,其他的不需要回复
if( m_pDBServer->getGameReady(pSession->nServerIndex) )
{
CDataPacket &data = allocProtoPacket(jxInterSrvComm::SessionServerProto::cConformOpenSession); //分配一个 网络包
data << (int)pSession->nSessionId ;
data << (int)pSession->nServerIndex;
flushProtoPacket(data);
}
}
VOID CDBSessionClient::OnCloseSession(int nSessionId)
{
//会话被关闭的同时需要向网关发送按全局会话ID关闭连接的消息
m_pDBServer->PostCloseGateUserBySessionId(nSessionId);
}
VOID CDBSessionClient::OnUpdateSessionState(CCustomGlobalSession* pSession, jxSrvDef::GSSTATE oldState, jxSrvDef::GSSTATE newState)
{
}
VOID CDBSessionClient::OnQuerySessionExists(INT_PTR nSessionId)
{
//异步的通过会话ID查询网关用户网关对此消息的返回将在内部消息分派函数中处理
m_pDBServer->PostQueryUserExistsBySessionId((int)nSessionId);
}