mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-27 17:28:41 +00:00
Network cleanup (#6302)
* Cleanup network headers * Move peerhandler to a specific header to reduce compilation times * Move socket.cpp/h to network folder * More work * Network code cleanups * Move socket.{cpp,h} to network folder * Move Address object to network/address.{cpp,h} * Move network exceptions to network/networkexceptions.h * Client: use unique_ptr for Connection * Server/ClientIface: use shared_ptr for Connection * Format fixes * Remove socket.cpp socket.h from clang-format whitelist * Also fix NetworkPacket code style & make it under clang-format
This commit is contained in:
parent
928609c8bd
commit
c7160cb629
27 changed files with 1059 additions and 924 deletions
|
@ -20,8 +20,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#pragma once
|
||||
|
||||
#include "irrlichttypes_bloated.h"
|
||||
#include "peerhandler.h"
|
||||
#include "socket.h"
|
||||
#include "exceptions.h"
|
||||
#include "constants.h"
|
||||
#include "util/pointer.h"
|
||||
#include "util/container.h"
|
||||
|
@ -37,89 +37,6 @@ class NetworkPacket;
|
|||
namespace con
|
||||
{
|
||||
|
||||
/*
|
||||
Exceptions
|
||||
*/
|
||||
class NotFoundException : public BaseException
|
||||
{
|
||||
public:
|
||||
NotFoundException(const char *s):
|
||||
BaseException(s)
|
||||
{}
|
||||
};
|
||||
|
||||
class PeerNotFoundException : public BaseException
|
||||
{
|
||||
public:
|
||||
PeerNotFoundException(const char *s):
|
||||
BaseException(s)
|
||||
{}
|
||||
};
|
||||
|
||||
class ConnectionException : public BaseException
|
||||
{
|
||||
public:
|
||||
ConnectionException(const char *s):
|
||||
BaseException(s)
|
||||
{}
|
||||
};
|
||||
|
||||
class ConnectionBindFailed : public BaseException
|
||||
{
|
||||
public:
|
||||
ConnectionBindFailed(const char *s):
|
||||
BaseException(s)
|
||||
{}
|
||||
};
|
||||
|
||||
class InvalidIncomingDataException : public BaseException
|
||||
{
|
||||
public:
|
||||
InvalidIncomingDataException(const char *s):
|
||||
BaseException(s)
|
||||
{}
|
||||
};
|
||||
|
||||
class InvalidOutgoingDataException : public BaseException
|
||||
{
|
||||
public:
|
||||
InvalidOutgoingDataException(const char *s):
|
||||
BaseException(s)
|
||||
{}
|
||||
};
|
||||
|
||||
class NoIncomingDataException : public BaseException
|
||||
{
|
||||
public:
|
||||
NoIncomingDataException(const char *s):
|
||||
BaseException(s)
|
||||
{}
|
||||
};
|
||||
|
||||
class ProcessedSilentlyException : public BaseException
|
||||
{
|
||||
public:
|
||||
ProcessedSilentlyException(const char *s):
|
||||
BaseException(s)
|
||||
{}
|
||||
};
|
||||
|
||||
class ProcessedQueued : public BaseException
|
||||
{
|
||||
public:
|
||||
ProcessedQueued(const char *s):
|
||||
BaseException(s)
|
||||
{}
|
||||
};
|
||||
|
||||
class IncomingDataCorruption : public BaseException
|
||||
{
|
||||
public:
|
||||
IncomingDataCorruption(const char *s):
|
||||
BaseException(s)
|
||||
{}
|
||||
};
|
||||
|
||||
typedef enum MTProtocols {
|
||||
MTP_PRIMARY,
|
||||
MTP_UDP,
|
||||
|
@ -566,41 +483,6 @@ private:
|
|||
|
||||
class Peer;
|
||||
|
||||
enum PeerChangeType
|
||||
{
|
||||
PEER_ADDED,
|
||||
PEER_REMOVED
|
||||
};
|
||||
struct PeerChange
|
||||
{
|
||||
PeerChange(PeerChangeType t, u16 _peer_id, bool _timeout):
|
||||
type(t), peer_id(_peer_id), timeout(_timeout) {}
|
||||
PeerChange() = delete;
|
||||
|
||||
PeerChangeType type;
|
||||
u16 peer_id;
|
||||
bool timeout;
|
||||
};
|
||||
|
||||
class PeerHandler
|
||||
{
|
||||
public:
|
||||
|
||||
PeerHandler() = default;
|
||||
virtual ~PeerHandler() = default;
|
||||
|
||||
/*
|
||||
This is called after the Peer has been inserted into the
|
||||
Connection's peer container.
|
||||
*/
|
||||
virtual void peerAdded(Peer *peer) = 0;
|
||||
/*
|
||||
This is called before the Peer has been removed from the
|
||||
Connection's peer container.
|
||||
*/
|
||||
virtual void deletingPeer(Peer *peer, bool timeout) = 0;
|
||||
};
|
||||
|
||||
class PeerHelper
|
||||
{
|
||||
public:
|
||||
|
@ -620,15 +502,6 @@ private:
|
|||
|
||||
class Connection;
|
||||
|
||||
typedef enum {
|
||||
MIN_RTT,
|
||||
MAX_RTT,
|
||||
AVG_RTT,
|
||||
MIN_JITTER,
|
||||
MAX_JITTER,
|
||||
AVG_JITTER
|
||||
} rtt_stat_type;
|
||||
|
||||
typedef enum {
|
||||
CUR_DL_RATE,
|
||||
AVG_DL_RATE,
|
||||
|
@ -974,6 +847,8 @@ private:
|
|||
Connection *m_connection = nullptr;
|
||||
};
|
||||
|
||||
class PeerHandler;
|
||||
|
||||
class Connection
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue