Simplification of discovery events

This commit is contained in:
HikikoMarmy
2025-07-01 15:11:11 +01:00
parent aa0129b5b0
commit 256a8c55c2
3 changed files with 12 additions and 15 deletions

View File

@@ -220,8 +220,7 @@ bool GameSessionManager::RequestOpen( sptr_user user )
session->m_state = GameSession::GameState::Open;
// Tell the host its own address.
NotifyGameDiscovered msg( user->m_discoveryAddr, user->m_discoveryPort, user->m_gameType );
user->sock->send( msg );
user->sock->send( NotifyGameDiscovered( user ) );
Log::Info( "Game Session [{}] Discoverable on {}", gameId, user->m_discoveryAddr );
@@ -403,12 +402,10 @@ std::vector<sptr_game_session> GameSessionManager::GetPrivateGameSessionList( co
void GameSessionManager::ProcessJoinNorrath( sptr_user join, sptr_user host )
{
// Tell the joining user its own address
NotifyClientDiscovered msgClientDiscovered( join );
join->sock->send( msgClientDiscovered );
join->sock->send( NotifyClientDiscovered( join ) );
// Tell the host the joining user's address.
NotifyClientRequestConnect msgNotifyReqConnect( join );
host->sock->send( msgNotifyReqConnect );
host->sock->send( NotifyClientRequestConnect( join ) );
}
void GameSessionManager::ProcessJoinArms( sptr_user join, sptr_user host )
@@ -420,10 +417,8 @@ void GameSessionManager::ProcessJoinArms( sptr_user join, sptr_user host )
host->m_localAddr, host->m_localPort, host->m_discoveryAddr, host->m_discoveryPort );
// Tell the joining user its own address
NotifyClientDiscovered_RTA msgClientDiscovered( join );
join->sock->send( msgClientDiscovered );
join->sock->send( NotifyClientDiscovered_RTA( join ) );
// Tell the host the joining user's address.
NotifyClientRequestConnect_RTA msgNotifyReqConnect( join );
host->sock->send( msgNotifyReqConnect );
host->sock->send( NotifyClientRequestConnect_RTA( join ) );
}

View File

@@ -1,10 +1,11 @@
#include "NotifyGameDiscovered.h"
#include "../../Game/RealmUser.h"
NotifyGameDiscovered::NotifyGameDiscovered( std::string clientIp, int32_t clientPort, RealmGameType clientType ) : GenericMessage( 0x3E )
NotifyGameDiscovered::NotifyGameDiscovered( sptr_user user ) : GenericMessage( 0x3E )
{
this->m_clientIp = std::move( clientIp );
this->m_clientPort = clientPort;
this->m_clientType = clientType;
this->m_clientIp = user->m_discoveryAddr;
this->m_clientPort = user->m_discoveryPort;
this->m_clientType = user->m_gameType;
}
void NotifyGameDiscovered::Serialize( ByteBuffer &out ) const

View File

@@ -5,6 +5,7 @@
#include "../GenericNetMessage.h"
#include "../../Common/Constant.h"
#include "../../Common/ForwardDecl.h"
class NotifyGameDiscovered : public GenericMessage {
private:
@@ -13,6 +14,6 @@ private:
RealmGameType m_clientType;
public:
NotifyGameDiscovered( std::string clientIp, int32_t clientPort, RealmGameType clientType );
NotifyGameDiscovered( sptr_user user );
void Serialize(ByteBuffer &out) const override;
};