1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-25 14:07:46 +00:00
sapphire/src/servers/sapphire_lobby/GameConnection.h

87 lines
2.3 KiB
C
Raw Normal View History

2017-08-08 13:53:47 +02:00
#ifndef GAMECONNECTION_H
#define GAMECONNECTION_H
2018-03-06 22:22:19 +01:00
#include <Network/Connection.h>
#include <Network/Acceptor.h>
#include <Network/CommonNetwork.h>
2017-08-08 13:53:47 +02:00
2018-03-06 22:22:19 +01:00
#include <Network/GamePacket.h>
#include <Network/PacketContainer.h>
#include <Util/LockedQueue.h>
2017-08-08 13:53:47 +02:00
#include "LobbyPacketContainer.h"
2017-08-08 13:53:47 +02:00
#include "Forwards.h"
#define DECLARE_HANDLER( x ) void x( Packets::GamePacketPtr pInPacket, Entity::PlayerPtr pPlayer )
namespace Core {
namespace Network {
class GameConnection : public Connection
{
private:
// TODO move the next three params to the session, makes more sense there
// encryption key
uint8_t m_encKey[0x10];
// base key, the encryption key is generated from this
uint8_t m_baseKey[0x2C];
bool m_bEncryptionInitialized;
AcceptorPtr m_pAcceptor;
LobbySessionPtr m_pSession;
LockedQueue< Packets::GamePacketPtr > m_inQueue;
LockedQueue< Packets::GamePacketPtr > m_outQueue;
public:
GameConnection( HivePtr pHive, AcceptorPtr pAcceptor );
~GameConnection();
void generateEncryptionKey( uint32_t key, const std::string& keyPhrase );
// overwrite the parents onConnect for our game socket needs
void OnAccept( const std::string & host, uint16_t port ) override;
void OnDisconnect() override;
void OnRecv( std::vector< uint8_t > & buffer ) override;
void OnError( const boost::system::error_code & error ) override;
void sendError( uint64_t sequence, uint32_t errorcode, uint16_t messageId, uint32_t tmpId );
void getCharList( Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
void enterWorld( Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
bool sendServiceAccountList( Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
bool createOrModifyChar( Packets::FFXIVARR_PACKET_RAW& packet, uint32_t tmpId );
void handlePackets( const Packets::FFXIVARR_PACKET_HEADER& ipcHeader,
const std::vector<Packets::FFXIVARR_PACKET_RAW>& packetData );
void handleGamePacket( Packets::FFXIVARR_PACKET_RAW &pPacket );
void handlePacket( Packets::GamePacketPtr pPacket );
2017-08-08 13:53:47 +02:00
void sendPackets( Packets::PacketContainer * pPacket );
void sendPacket( Packets::LobbyPacketContainer& pLpc );
void sendSinglePacket( Packets::GamePacket * pPacket );
void sendSinglePacket( Packets::GamePacket & pPacket );
};
}
}
#endif