mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-25 16:30:15 +00:00
Initial commit: wowee native WoW 3.3.5a client
This commit is contained in:
commit
ce6cb8f38e
147 changed files with 32347 additions and 0 deletions
96
include/auth/auth_handler.hpp
Normal file
96
include/auth/auth_handler.hpp
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
#pragma once
|
||||
|
||||
#include "auth/srp.hpp"
|
||||
#include "auth/auth_packets.hpp"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
namespace wowee {
|
||||
namespace network { class TCPSocket; class Packet; }
|
||||
|
||||
namespace auth {
|
||||
|
||||
struct Realm;
|
||||
|
||||
// Authentication state
|
||||
enum class AuthState {
|
||||
DISCONNECTED,
|
||||
CONNECTED,
|
||||
CHALLENGE_SENT,
|
||||
CHALLENGE_RECEIVED,
|
||||
PROOF_SENT,
|
||||
AUTHENTICATED,
|
||||
REALM_LIST_REQUESTED,
|
||||
REALM_LIST_RECEIVED,
|
||||
FAILED
|
||||
};
|
||||
|
||||
// Authentication callbacks
|
||||
using AuthSuccessCallback = std::function<void(const std::vector<uint8_t>& sessionKey)>;
|
||||
using AuthFailureCallback = std::function<void(const std::string& reason)>;
|
||||
using RealmListCallback = std::function<void(const std::vector<Realm>& realms)>;
|
||||
|
||||
class AuthHandler {
|
||||
public:
|
||||
AuthHandler();
|
||||
~AuthHandler();
|
||||
|
||||
// Connection
|
||||
bool connect(const std::string& host, uint16_t port = 3724);
|
||||
void disconnect();
|
||||
bool isConnected() const;
|
||||
|
||||
// Authentication
|
||||
void authenticate(const std::string& username, const std::string& password);
|
||||
|
||||
// Realm list
|
||||
void requestRealmList();
|
||||
const std::vector<Realm>& getRealms() const { return realms; }
|
||||
|
||||
// State
|
||||
AuthState getState() const { return state; }
|
||||
const std::vector<uint8_t>& getSessionKey() const { return sessionKey; }
|
||||
|
||||
// Callbacks
|
||||
void setOnSuccess(AuthSuccessCallback callback) { onSuccess = callback; }
|
||||
void setOnFailure(AuthFailureCallback callback) { onFailure = callback; }
|
||||
void setOnRealmList(RealmListCallback callback) { onRealmList = callback; }
|
||||
|
||||
// Update (call each frame)
|
||||
void update(float deltaTime);
|
||||
|
||||
private:
|
||||
void sendLogonChallenge();
|
||||
void handleLogonChallengeResponse(network::Packet& packet);
|
||||
void sendLogonProof();
|
||||
void handleLogonProofResponse(network::Packet& packet);
|
||||
void sendRealmListRequest();
|
||||
void handleRealmListResponse(network::Packet& packet);
|
||||
void handlePacket(network::Packet& packet);
|
||||
|
||||
void setState(AuthState newState);
|
||||
void fail(const std::string& reason);
|
||||
|
||||
std::unique_ptr<network::TCPSocket> socket;
|
||||
std::unique_ptr<SRP> srp;
|
||||
|
||||
AuthState state = AuthState::DISCONNECTED;
|
||||
std::string username;
|
||||
std::string password;
|
||||
ClientInfo clientInfo;
|
||||
|
||||
std::vector<uint8_t> sessionKey;
|
||||
std::vector<Realm> realms;
|
||||
|
||||
// Callbacks
|
||||
AuthSuccessCallback onSuccess;
|
||||
AuthFailureCallback onFailure;
|
||||
RealmListCallback onRealmList;
|
||||
|
||||
// Receive buffer
|
||||
std::vector<uint8_t> receiveBuffer;
|
||||
};
|
||||
|
||||
} // namespace auth
|
||||
} // namespace wowee
|
||||
Loading…
Add table
Add a link
Reference in a new issue