Files
git 9cb257e7ae Add GameClients drops and keep current 1602 source work.
CN1602 is the local client. KR is the official tree with unpacked Data, System, and Sound. Packed .wpk files stay off git.
2026-08-30 23:24:31 +03:00

104 lines
2.3 KiB
C++

#include "stdafx.h"
#include "ServerSession.h"
#include "ServerSessionManager.h"
#include "../Information/ScriptLoadManager.h"
#include "../Information/SolarAcceptableMasterServerListLoader.h"
//private:
// <INTERNAL><INTERFACEs>
ServerSessionManager::ServerSessionManager()
{
_Initialize();
}
ServerSessionManager::~ServerSessionManager()
{
SAFE_DELETE( AcceptedSessions.REFERENCE() );
SAFE_DELETE( ConnectedSessions.REFERENCE() );
}
VOID ServerSessionManager::_Initialize()
{
AcceptedSessions.REFERENCE() = new SERVER_SESSION_MAP();
ConnectedSessions.REFERENCE() = new SERVER_SESSION_CONTAINER();
m_EmptySession.REFERENCE() = NULL;
ScriptLoadManager* pManager = ScriptLoadManager::Instance();
pManager->LoadAcceptableMasterServerList();
}
VOID ServerSessionManager::AddServer( SERVER_SESSION_DELEGATOR pServer )
{
DWORD dwKey = (DWORD)(__int64)pServer();
SERVER_SESSION_CONTAINER_ITER it = ConnectedSessions->find( dwKey );
if( it != ConnectedSessions->end() )
{
ASSERT( !"Trying to add a duplicated server." );
return;
}
ConnectedSessions->insert(
ConnectedSessions->end(),
SERVER_SESSION_CONTAINER_PAIR( dwKey, pServer )
);
}
VOID ServerSessionManager::RemoveServer( SERVER_SESSION_DELEGATOR pServer )
{
DWORD dwKey = (DWORD)(__int64)pServer();
SERVER_SESSION_CONTAINER_ITER it = ConnectedSessions->find( dwKey );
if( it == ConnectedSessions->end() )
{
ASSERT( !"Trying to remove a server that does not exist." );
return;
}
ConnectedSessions->erase( it );
}
SERVER_SESSION_DELEGATOR&
ServerSessionManager::FindServer( SERVER_SESSION_DELEGATOR pServer )
{
DWORD dwKey = (DWORD)(__int64)pServer();
SERVER_SESSION_MAP_ITER it = ConnectedSessions->find( dwKey );
if( it == ConnectedSessions->end() )
return m_EmptySession;
return it->second;
}
VOID ServerSessionManager::Update()
{
for_each(
ConnectedSessions->begin(),
ConnectedSessions->end(),
bind1st(mem_fun(&ServerSessionManager::_UpdateSession), this)
);
}
// 접속되어 있는 마스터서버들에게 브로드캐스팅
VOID ServerSessionManager::SendToMasterServers( BYTE* pMsg, WORD wSize )
{
}
VOID ServerSessionManager::_UpdateSession( SERVER_SESSION_PAIR node )
{
SERVER_SESSION_DELEGATOR pSession = node.second;
if( pSession != NULL )
pSession->Update();
}
VOID ServerSessionManager::_DeleteSession( SERVER_SESSION_PAIR node )
{
}