mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-05 07:16:18 +00:00
refactor client disconnect, client interation
anywhere a client is disconnected, TNetwork::Disconnect is called now. Nothing else is valid. ForEachClientWeak() was fully removed.
This commit is contained in:
@@ -44,7 +44,6 @@ public:
|
||||
void SetIdentifier(const std::string& key, const std::string& value);
|
||||
std::string GetCarData(int Ident);
|
||||
std::string GetCarPositionRaw(int Ident);
|
||||
void Disconnect(std::string_view Reason);
|
||||
bool IsDisconnected() const { return !TCPSocket->is_open(); }
|
||||
// locks
|
||||
void DeleteCar(int Ident);
|
||||
@@ -75,7 +74,12 @@ public:
|
||||
Sync<std::queue<std::vector<uint8_t>>> MissedPacketsQueue;
|
||||
Sync<std::chrono::time_point<std::chrono::high_resolution_clock>> LastPingTime;
|
||||
|
||||
friend class TNetwork;
|
||||
|
||||
private:
|
||||
/// ONLY call after the client has been cleaned up, all cars deleted, etc.
|
||||
void CloseSockets(std::string_view Reason);
|
||||
|
||||
void InsertVehicle(int ID, const std::string& Data);
|
||||
|
||||
TServer& mServer;
|
||||
|
||||
@@ -19,6 +19,9 @@ public:
|
||||
std::shared_ptr<TClient> CreateClient(ip::tcp::socket&& TCPSock);
|
||||
std::vector<uint8_t> TCPRcv(TClient& c);
|
||||
void ClientKick(TClient& c, const std::string& R);
|
||||
void Disconnect(const std::shared_ptr<TClient>& ClientPtr);
|
||||
void Disconnect(const std::weak_ptr<TClient>& ClientPtr);
|
||||
void Disconnect(TClient& Client);
|
||||
[[nodiscard]] bool SyncClient(const std::weak_ptr<TClient>& c);
|
||||
void Identify(TConnection&& client);
|
||||
std::shared_ptr<TClient> Authentication(TConnection&& ClientConnection);
|
||||
@@ -43,14 +46,11 @@ private:
|
||||
void OnConnect(const std::weak_ptr<TClient>& c);
|
||||
void TCPClient(const std::weak_ptr<TClient>& c);
|
||||
void Looper(const std::weak_ptr<TClient>& c);
|
||||
void OnDisconnect(const std::shared_ptr<TClient>& ClientPtr);
|
||||
void OnDisconnect(const std::weak_ptr<TClient>& ClientPtr);
|
||||
void OnDisconnect(TClient& Client);
|
||||
void Parse(TClient& c, const std::vector<uint8_t>& Packet);
|
||||
void SendFile(TClient& c, const std::string& Name);
|
||||
static bool TCPSendRaw(TClient& C, ip::tcp::socket& socket, const uint8_t* Data, size_t Size);
|
||||
static void SplitLoad(TClient& c, size_t Sent, size_t Size, bool D, const std::string& Name);
|
||||
static const uint8_t* SendSplit(TClient& c, ip::tcp::socket& Socket, const uint8_t* DataPtr, size_t Size);
|
||||
bool TCPSendRaw(TClient& C, ip::tcp::socket& socket, const uint8_t* Data, size_t Size);
|
||||
void SplitLoad(TClient& c, size_t Sent, size_t Size, bool D, const std::string& Name);
|
||||
const uint8_t* SendSplit(TClient& c, ip::tcp::socket& Socket, const uint8_t* DataPtr, size_t Size);
|
||||
};
|
||||
|
||||
std::string HashPassword(const std::string& str);
|
||||
|
||||
@@ -24,7 +24,6 @@ public:
|
||||
void RemoveClient(const std::weak_ptr<TClient>&);
|
||||
void RemoveClient(TClient&);
|
||||
// in Fn, return true to continue, return false to break
|
||||
[[deprecated("Use ForEachClient instead")]] void ForEachClientWeak(const std::function<bool(std::weak_ptr<TClient>)>& Fn);
|
||||
void ForEachClient(const std::function<bool(const std::shared_ptr<TClient>&)> Fn);
|
||||
size_t ClientCount() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user