summaryrefslogtreecommitdiff
path: root/src/network/connection.h
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-08-24 08:28:54 +0200
committerGitHub <noreply@github.com>2017-08-24 08:28:54 +0200
commitc7160cb629086df2a32c7dcf4faed4761ec4393e (patch)
tree63670a536ce95f6a3a1ce09bf2f2f65d1bec5214 /src/network/connection.h
parent928609c8bd9d4e6129ab244214bd5c54d000b737 (diff)
downloadminetest-c7160cb629086df2a32c7dcf4faed4761ec4393e.tar.gz
minetest-c7160cb629086df2a32c7dcf4faed4761ec4393e.tar.bz2
minetest-c7160cb629086df2a32c7dcf4faed4761ec4393e.zip
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
Diffstat (limited to 'src/network/connection.h')
-rw-r--r--src/network/connection.h131
1 files changed, 3 insertions, 128 deletions
diff --git a/src/network/connection.h b/src/network/connection.h
index c0a39f313..3d3a502aa 100644
--- a/src/network/connection.h
+++ b/src/network/connection.h
@@ -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:
@@ -621,15 +503,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,
CUR_INC_RATE,
@@ -974,6 +847,8 @@ private:
Connection *m_connection = nullptr;
};
+class PeerHandler;
+
class Connection
{
public: