mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-05 18:27:47 +00:00
Great improved connection stability when connecting to a remote world-server
This commit is contained in:
parent
8105473992
commit
66be114dc7
2 changed files with 7 additions and 26 deletions
|
@ -154,45 +154,25 @@ void Sapphire::Network::GameConnection::onDisconnect()
|
||||||
|
|
||||||
void Sapphire::Network::GameConnection::onRecv( std::vector< uint8_t >& buffer )
|
void Sapphire::Network::GameConnection::onRecv( std::vector< uint8_t >& buffer )
|
||||||
{
|
{
|
||||||
|
m_packets.insert( std::end( m_packets ), std::begin( buffer ), std::end( buffer ) );
|
||||||
// This is assumed packet always start with valid FFXIVARR_PACKET_HEADER for now.
|
// This is assumed packet always start with valid FFXIVARR_PACKET_HEADER for now.
|
||||||
Packets::FFXIVARR_PACKET_HEADER packetHeader{};
|
Packets::FFXIVARR_PACKET_HEADER packetHeader{};
|
||||||
const auto headerResult = Packets::getHeader( buffer, 0, packetHeader );
|
const auto headerResult = Packets::getHeader( m_packets, 0, packetHeader );
|
||||||
|
|
||||||
if( headerResult == Incomplete )
|
if( ( headerResult == Incomplete ) || ( headerResult == Malformed ) )
|
||||||
{
|
|
||||||
Logger::info( "Dropping connection due to incomplete packet header." );
|
|
||||||
Logger::info( "FIXME: Packet message bounary is not implemented." );
|
|
||||||
disconnect();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
else if( headerResult == Malformed )
|
|
||||||
{
|
|
||||||
Logger::info( "Dropping connection due to malformed packet header." );
|
|
||||||
disconnect();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dissect packet list
|
// Dissect packet list
|
||||||
std::vector< Packets::FFXIVARR_PACKET_RAW > packetList;
|
std::vector< Packets::FFXIVARR_PACKET_RAW > packetList;
|
||||||
const auto packetResult = Packets::getPackets( buffer, sizeof( struct FFXIVARR_PACKET_HEADER ),
|
const auto packetResult = Packets::getPackets( m_packets, sizeof( struct FFXIVARR_PACKET_HEADER ),
|
||||||
packetHeader, packetList );
|
packetHeader, packetList );
|
||||||
|
|
||||||
if( packetResult == Incomplete )
|
if( ( packetResult == Incomplete ) || ( packetResult == Malformed ) )
|
||||||
{
|
|
||||||
Logger::info( "Dropping connection due to incomplete packets." );
|
|
||||||
Logger::info( "FIXME: Packet message bounary is not implemented." );
|
|
||||||
disconnect();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
else if( packetResult == Malformed )
|
|
||||||
{
|
|
||||||
Logger::info( "Dropping connection due to malformed packets." );
|
|
||||||
disconnect();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle it
|
// Handle it
|
||||||
handlePackets( packetHeader, packetList );
|
handlePackets( packetHeader, packetList );
|
||||||
|
m_packets.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sapphire::Network::GameConnection::onError( const asio::error_code& error )
|
void Sapphire::Network::GameConnection::onError( const asio::error_code& error )
|
||||||
|
|
|
@ -53,6 +53,7 @@ namespace Sapphire::Network
|
||||||
|
|
||||||
LockedQueue< Sapphire::Network::Packets::FFXIVARR_PACKET_RAW > m_inQueue;
|
LockedQueue< Sapphire::Network::Packets::FFXIVARR_PACKET_RAW > m_inQueue;
|
||||||
LockedQueue< Packets::FFXIVPacketBasePtr > m_outQueue;
|
LockedQueue< Packets::FFXIVPacketBasePtr > m_outQueue;
|
||||||
|
std::vector< uint8_t > m_packets;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConnectionType m_conType;
|
ConnectionType m_conType;
|
||||||
|
|
Loading…
Add table
Reference in a new issue