From c7160cb629086df2a32c7dcf4faed4761ec4393e Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Thu, 24 Aug 2017 08:28:54 +0200 Subject: 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 --- src/network/connection.h | 131 ++--------------------------------------------- 1 file changed, 3 insertions(+), 128 deletions(-) (limited to 'src/network/connection.h') 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: @@ -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: -- cgit v1.2.3