238 lines
5.0 KiB
C++
238 lines
5.0 KiB
C++
|
|
#include "StdAfx.h"
|
|||
|
|
#include "AfxTempl.h"
|
|||
|
|
#include "LockTimeMatch.h"
|
|||
|
|
#include "ImmediateMatch.h"
|
|||
|
|
#include "MatchServiceManager.h"
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>캯<EFBFBD><ECBAAF>
|
|||
|
|
CMatchServiceManager::CMatchServiceManager(void)
|
|||
|
|
{
|
|||
|
|
//״̬<D7B4><CCAC><EFBFBD><EFBFBD>
|
|||
|
|
m_bIsService=false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
m_pIGameMatchItem=NULL;
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMatchServiceManager::~CMatchServiceManager(void)
|
|||
|
|
{
|
|||
|
|
//<2F>ͷ<EFBFBD>ָ<EFBFBD><D6B8>
|
|||
|
|
if(m_pIGameMatchItem!=NULL) SafeDelete(m_pIGameMatchItem);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
|
|||
|
|
bool CMatchServiceManager::StopService()
|
|||
|
|
{
|
|||
|
|
//״̬<D7B4>ж<EFBFBD>
|
|||
|
|
ASSERT(m_bIsService==true);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>״̬
|
|||
|
|
m_bIsService=false;
|
|||
|
|
|
|||
|
|
//<2F>ͷ<EFBFBD>ָ<EFBFBD><D6B8>
|
|||
|
|
if(m_pIGameMatchItem!=NULL) SafeRelease(m_pIGameMatchItem);
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CMatchServiceManager::StartService()
|
|||
|
|
{
|
|||
|
|
//״̬<D7B4>ж<EFBFBD>
|
|||
|
|
ASSERT(m_bIsService==false);
|
|||
|
|
if(m_bIsService==true) return false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>״̬
|
|||
|
|
m_bIsService=true;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>֪ͨ
|
|||
|
|
if(m_pIGameMatchItem!=NULL) m_pIGameMatchItem->OnStartService();
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
//<2F>ӿڲ<D3BF>ѯ
|
|||
|
|
void * CMatchServiceManager::QueryInterface(const IID & Guid, DWORD dwQueryVer)
|
|||
|
|
{
|
|||
|
|
QUERYINTERFACE(IMatchServiceManager,Guid,dwQueryVer);
|
|||
|
|
QUERYINTERFACE_IUNKNOWNEX(IMatchServiceManager,Guid,dwQueryVer);
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CMatchServiceManager::CreateGameMatch(BYTE cbMatchType)
|
|||
|
|
{
|
|||
|
|
//<2F>ӿ<EFBFBD><D3BF>ж<EFBFBD>
|
|||
|
|
ASSERT(m_pIGameMatchItem==NULL);
|
|||
|
|
if(m_pIGameMatchItem!=NULL) return false;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//<2F><>ʱ<EFBFBD><CAB1>
|
|||
|
|
if(cbMatchType==MATCH_TYPE_LOCKTIME)
|
|||
|
|
{
|
|||
|
|
m_pIGameMatchItem = new CLockTimeMatch();
|
|||
|
|
if(m_pIGameMatchItem==NULL) throw TEXT("<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ʱ<EFBFBD><CAB1>
|
|||
|
|
if(cbMatchType==MATCH_TYPE_IMMEDIATE)
|
|||
|
|
{
|
|||
|
|
m_pIGameMatchItem = new CImmediateMatch();
|
|||
|
|
if(m_pIGameMatchItem==NULL) throw TEXT("<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch(...)
|
|||
|
|
{
|
|||
|
|
ASSERT(FALSE);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return m_pIGameMatchItem!=NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD>
|
|||
|
|
bool CMatchServiceManager::BindTableFrame(ITableFrame * pTableFrame,WORD wTableID)
|
|||
|
|
{
|
|||
|
|
ASSERT(m_pIGameMatchItem!=NULL);
|
|||
|
|
if(m_pIGameMatchItem!=NULL)
|
|||
|
|
{
|
|||
|
|
return m_pIGameMatchItem->BindTableFrame(pTableFrame,wTableID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>ӿ<EFBFBD>
|
|||
|
|
bool CMatchServiceManager::InitMatchInterface(tagMatchManagerParameter & MatchManagerParameter)
|
|||
|
|
{
|
|||
|
|
ASSERT(m_pIGameMatchItem!=NULL);
|
|||
|
|
if(m_pIGameMatchItem!=NULL)
|
|||
|
|
{
|
|||
|
|
return m_pIGameMatchItem->InitMatchInterface(MatchManagerParameter);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ʱ<><CAB1><EFBFBD>¼<EFBFBD>
|
|||
|
|
bool CMatchServiceManager::OnEventTimer(DWORD dwTimerID, WPARAM dwBindParameter)
|
|||
|
|
{
|
|||
|
|
ASSERT(m_pIGameMatchItem!=NULL);
|
|||
|
|
if(m_pIGameMatchItem!=NULL)
|
|||
|
|
{
|
|||
|
|
return m_pIGameMatchItem->OnEventTimer(dwTimerID,dwBindParameter);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ݿ<EFBFBD><DDBF>¼<EFBFBD>
|
|||
|
|
bool CMatchServiceManager::OnEventDataBase(WORD wRequestID, IServerUserItem * pIServerUserItem, VOID * pData, WORD wDataSize)
|
|||
|
|
{
|
|||
|
|
ASSERT(m_pIGameMatchItem!=NULL);
|
|||
|
|
if(m_pIGameMatchItem!=NULL)
|
|||
|
|
{
|
|||
|
|
return m_pIGameMatchItem->OnEventDataBase(wRequestID,pIServerUserItem,pData,wDataSize);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
bool CMatchServiceManager::OnEventSocketMatch(WORD wSubCmdID, VOID * pData, WORD wDataSize, IServerUserItem * pIServerUserItem, DWORD dwSocketID)
|
|||
|
|
{
|
|||
|
|
ASSERT(m_pIGameMatchItem!=NULL);
|
|||
|
|
if(m_pIGameMatchItem!=NULL)
|
|||
|
|
{
|
|||
|
|
return m_pIGameMatchItem->OnEventSocketMatch(wSubCmdID,pData,wDataSize,pIServerUserItem,dwSocketID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD>¼
|
|||
|
|
bool CMatchServiceManager::OnEventUserLogon(IServerUserItem * pIServerUserItem)
|
|||
|
|
{
|
|||
|
|
ASSERT(m_pIGameMatchItem!=NULL);
|
|||
|
|
if(m_pIGameMatchItem!=NULL)
|
|||
|
|
{
|
|||
|
|
return m_pIGameMatchItem->OnEventUserLogon(pIServerUserItem);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB>dz<EFBFBD>
|
|||
|
|
bool CMatchServiceManager::OnEventUserLogout(IServerUserItem * pIServerUserItem)
|
|||
|
|
{
|
|||
|
|
ASSERT(m_pIGameMatchItem!=NULL);
|
|||
|
|
if(m_pIGameMatchItem!=NULL)
|
|||
|
|
{
|
|||
|
|
return m_pIGameMatchItem->OnEventUserLogout(pIServerUserItem);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CMatchServiceManager::OnEventEnterMatch(DWORD dwSocketID,VOID* pData,DWORD dwUserIP, bool bIsMobile)
|
|||
|
|
{
|
|||
|
|
ASSERT(m_pIGameMatchItem!=NULL);
|
|||
|
|
if(m_pIGameMatchItem!=NULL)
|
|||
|
|
{
|
|||
|
|
return m_pIGameMatchItem->OnEventEnterMatch(dwSocketID, pData, dwUserIP, bIsMobile);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CMatchServiceManager::OnEventUserJoinMatch(IServerUserItem * pIServerUserItem, BYTE cbReason,DWORD dwSocketID)
|
|||
|
|
{
|
|||
|
|
ASSERT(m_pIGameMatchItem!=NULL);
|
|||
|
|
if(m_pIGameMatchItem!=NULL)
|
|||
|
|
{
|
|||
|
|
return m_pIGameMatchItem->OnEventUserJoinMatch(pIServerUserItem,cbReason,dwSocketID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CMatchServiceManager::OnEventUserQuitMatch(IServerUserItem * pIServerUserItem, BYTE cbReason,WORD *pBestRank, DWORD dwContextID)
|
|||
|
|
{
|
|||
|
|
ASSERT(m_pIGameMatchItem!=NULL);
|
|||
|
|
if(m_pIGameMatchItem!=NULL)
|
|||
|
|
{
|
|||
|
|
return m_pIGameMatchItem->OnEventUserQuitMatch(pIServerUserItem,cbReason,pBestRank,dwContextID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB>ӿ<EFBFBD>
|
|||
|
|
IUnknownEx * CMatchServiceManager::GetServerUserItemSink()
|
|||
|
|
{
|
|||
|
|
ASSERT(m_pIGameMatchItem!=NULL);
|
|||
|
|
if(m_pIGameMatchItem!=NULL)
|
|||
|
|
{
|
|||
|
|
return QUERY_OBJECT_PTR_INTERFACE(m_pIGameMatchItem,IServerUserItemSink);
|
|||
|
|
}
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
DECLARE_CREATE_MODULE(MatchServiceManager);
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////
|