mirror of
https://github.com/HikikoMarmy/Champions-Reborn-Server.git
synced 2026-04-05 08:59:54 -03:00
Reorganized and cleaned up the solution.
This commit is contained in:
55
Source/Network/Event/RequestGetPublicRooms.cpp
Normal file
55
Source/Network/Event/RequestGetPublicRooms.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "Network/Event/RequestGetPublicRooms.hpp"
|
||||
|
||||
#include "Game/ChatRoomManager.hpp"
|
||||
|
||||
void RequestGetPublicRooms::Deserialize( sptr_byte_stream stream )
|
||||
{
|
||||
DeserializeHeader( stream );
|
||||
}
|
||||
|
||||
sptr_generic_response RequestGetPublicRooms::ProcessRequest( sptr_socket socket, sptr_byte_stream stream )
|
||||
{
|
||||
Deserialize( stream );
|
||||
|
||||
const auto publicRooms = ChatRoomManager::Get().GetPublicRoomList();
|
||||
|
||||
return std::make_shared< ResultGetPublicRooms >( this, publicRooms );
|
||||
}
|
||||
|
||||
ResultGetPublicRooms::ResultGetPublicRooms( GenericRequest *request, std::vector< sptr_chat_room_session > rooms ) : GenericResponse( *request )
|
||||
{
|
||||
m_rooms = std::move( rooms );
|
||||
}
|
||||
|
||||
void ResultGetPublicRooms::Serialize( ByteBuffer &out ) const
|
||||
{
|
||||
out.write_u16( m_packetId );
|
||||
out.write_u32( m_trackId );
|
||||
out.write_u32( 0 );
|
||||
|
||||
const auto numRoom = static_cast< uint32_t >( m_rooms.size() );
|
||||
|
||||
out.write_u32( numRoom );
|
||||
for( const auto &room : m_rooms )
|
||||
{
|
||||
out.write_utf16( room->m_name );
|
||||
}
|
||||
|
||||
out.write_u32( numRoom );
|
||||
for( const auto &room : m_rooms )
|
||||
{
|
||||
out.write_utf16( L"UNKNOWN" );
|
||||
}
|
||||
|
||||
out.write_u32( numRoom );
|
||||
for( const auto &room : m_rooms )
|
||||
{
|
||||
out.write_u32( 88 );
|
||||
}
|
||||
|
||||
out.write_u32( numRoom );
|
||||
for( const auto &room : m_rooms )
|
||||
{
|
||||
out.write_u32( 99 );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user