Network: Get rid of now useless TcpBase
Former-commit-id: 5a682d6d58cc5e2b8bea19dbfc9acb1133b35337
This commit is contained in:
parent
1bbf038cc6
commit
2a70758f08
|
|
@ -1,42 +0,0 @@
|
|||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Network module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_TCPBASE_HPP
|
||||
#define NAZARA_TCPBASE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Network/AbstractSocket.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NETWORK_API TcpBase : public AbstractSocket
|
||||
{
|
||||
public:
|
||||
~TcpBase() = default;
|
||||
|
||||
inline bool IsLowDelayEnabled() const;
|
||||
inline bool IsKeepAliveEnabled() const;
|
||||
|
||||
// Slots
|
||||
NazaraSignal(OnStateChange, const TcpBase* /*socket*/, SocketState /*newState*/);
|
||||
|
||||
protected:
|
||||
TcpBase();
|
||||
TcpBase(TcpBase&& tcpBase);
|
||||
|
||||
virtual void OnOpened() override;
|
||||
|
||||
SocketState m_state;
|
||||
UInt64 m_keepAliveInterval;
|
||||
UInt64 m_keepAliveTime;
|
||||
bool m_isLowDelayEnabled;
|
||||
bool m_isKeepAliveEnabled;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Network/TcpBase.inl>
|
||||
|
||||
#endif // NAZARA_TCPBASE_HPP
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Network module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <utility>
|
||||
#include <Nazara/Network/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline TcpBase::TcpBase() :
|
||||
AbstractSocket(SocketType_TCP)
|
||||
{
|
||||
}
|
||||
|
||||
inline TcpBase::TcpBase(TcpBase&& tcpBase) :
|
||||
AbstractSocket(std::move(tcpBase)),
|
||||
m_state(tcpBase.m_state),
|
||||
m_keepAliveInterval(tcpBase.m_keepAliveInterval),
|
||||
m_keepAliveTime(tcpBase.m_keepAliveTime),
|
||||
m_isLowDelayEnabled(tcpBase.m_isLowDelayEnabled),
|
||||
m_isKeepAliveEnabled(tcpBase.m_isKeepAliveEnabled)
|
||||
{
|
||||
}
|
||||
|
||||
inline bool TcpBase::IsLowDelayEnabled() const
|
||||
{
|
||||
return m_isLowDelayEnabled;
|
||||
}
|
||||
|
||||
inline bool TcpBase::IsKeepAliveEnabled() const
|
||||
{
|
||||
return m_isKeepAliveEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Network/DebugOff.hpp>
|
||||
|
|
@ -9,17 +9,17 @@
|
|||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Network/TcpBase.hpp>
|
||||
#include <Nazara/Network/AbstractSocket.hpp>
|
||||
#include <Nazara/Network/IpAddress.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NETWORK_API TcpClient : public TcpBase
|
||||
class NAZARA_NETWORK_API TcpClient : public AbstractSocket
|
||||
{
|
||||
friend class TcpServer;
|
||||
|
||||
public:
|
||||
TcpClient() = default;
|
||||
inline TcpClient();
|
||||
inline TcpClient(TcpClient&& tcpClient);
|
||||
~TcpClient() = default;
|
||||
|
||||
|
|
@ -33,6 +33,9 @@ namespace Nz
|
|||
inline UInt64 GetKeepAliveTime() const;
|
||||
inline IpAddress GetRemoteAddress() const;
|
||||
|
||||
inline bool IsLowDelayEnabled() const;
|
||||
inline bool IsKeepAliveEnabled() const;
|
||||
|
||||
SocketState QueryState();
|
||||
|
||||
bool Receive(void* buffer, std::size_t size, std::size_t* received);
|
||||
|
|
@ -46,6 +49,10 @@ namespace Nz
|
|||
void Reset(SocketHandle handle, const IpAddress& peerAddress);
|
||||
|
||||
IpAddress m_peerAddress;
|
||||
UInt64 m_keepAliveInterval;
|
||||
UInt64 m_keepAliveTime;
|
||||
bool m_isLowDelayEnabled;
|
||||
bool m_isKeepAliveEnabled;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,18 @@
|
|||
|
||||
namespace Nz
|
||||
{
|
||||
inline TcpClient::TcpClient() :
|
||||
AbstractSocket(SocketType_TCP)
|
||||
{
|
||||
}
|
||||
|
||||
inline TcpClient::TcpClient(TcpClient&& tcpClient) :
|
||||
TcpBase(std::move(tcpClient)),
|
||||
m_peerAddress(std::move(tcpClient.m_peerAddress))
|
||||
AbstractSocket(std::move(tcpClient)),
|
||||
m_peerAddress(std::move(tcpClient.m_peerAddress)),
|
||||
m_keepAliveInterval(tcpClient.m_keepAliveInterval),
|
||||
m_keepAliveTime(tcpClient.m_keepAliveTime),
|
||||
m_isLowDelayEnabled(tcpClient.m_isLowDelayEnabled),
|
||||
m_isKeepAliveEnabled(tcpClient.m_isKeepAliveEnabled)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -32,6 +41,16 @@ namespace Nz
|
|||
{
|
||||
return m_peerAddress;
|
||||
}
|
||||
|
||||
inline bool TcpClient::IsLowDelayEnabled() const
|
||||
{
|
||||
return m_isLowDelayEnabled;
|
||||
}
|
||||
|
||||
inline bool TcpClient::IsKeepAliveEnabled() const
|
||||
{
|
||||
return m_isKeepAliveEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Network/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -8,17 +8,17 @@
|
|||
#define NAZARA_TCPSERVER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Network/TcpBase.hpp>
|
||||
#include <Nazara/Network/AbstractSocket.hpp>
|
||||
#include <Nazara/Network/IpAddress.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class TcpClient;
|
||||
|
||||
class NAZARA_NETWORK_API TcpServer : public TcpBase
|
||||
class NAZARA_NETWORK_API TcpServer : public AbstractSocket
|
||||
{
|
||||
public:
|
||||
TcpServer() = default;
|
||||
inline TcpServer();
|
||||
inline TcpServer(TcpServer&& tcpServer);
|
||||
~TcpServer() = default;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,13 @@
|
|||
|
||||
namespace Nz
|
||||
{
|
||||
inline TcpServer::TcpServer() :
|
||||
AbstractSocket(SocketType_TCP)
|
||||
{
|
||||
}
|
||||
|
||||
inline TcpServer::TcpServer(TcpServer&& tcpServer) :
|
||||
TcpBase(std::move(tcpServer)),
|
||||
AbstractSocket(std::move(tcpServer)),
|
||||
m_boundAddress(std::move(tcpServer.m_boundAddress))
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Network/TcpBase.hpp>
|
||||
#include <Nazara/Core/CallOnExit.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <limits>
|
||||
#include <Nazara/Network/Debug.hpp>
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
#include <Nazara/Network/Win32/SocketImpl.hpp>
|
||||
#else
|
||||
#error Missing implementation: Socket
|
||||
#endif
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
void TcpBase::OnOpened()
|
||||
{
|
||||
AbstractSocket::OnOpened();
|
||||
|
||||
m_isLowDelayEnabled = false; //< Nagle's algorithm, is this enabled everywhere?
|
||||
m_isKeepAliveEnabled = false; //< default documentation value, OS can change this (TODO: Query OS default value)
|
||||
m_keepAliveInterval = 1000; //< default documentation value, OS can change this (TODO: Query OS default value)
|
||||
m_keepAliveTime = 7200000; //< default documentation value, OS can change this (TODO: Query OS default value)
|
||||
|
||||
ChangeState(SocketState_NotConnected);
|
||||
}
|
||||
}
|
||||
|
|
@ -187,15 +187,19 @@ namespace Nz
|
|||
|
||||
void TcpClient::OnClose()
|
||||
{
|
||||
TcpBase::OnClose();
|
||||
AbstractSocket::OnClose();
|
||||
|
||||
m_peerAddress = IpAddress::Invalid;
|
||||
}
|
||||
|
||||
void TcpClient::OnOpened()
|
||||
{
|
||||
TcpBase::OnOpened();
|
||||
AbstractSocket::OnOpened();
|
||||
|
||||
m_isLowDelayEnabled = false; //< Nagle's algorithm, is this enabled everywhere?
|
||||
m_isKeepAliveEnabled = false; //< default documentation value, OS can change this (TODO: Query OS default value)
|
||||
m_keepAliveInterval = 1000; //< default documentation value, OS can change this (TODO: Query OS default value)
|
||||
m_keepAliveTime = 7200000; //< default documentation value, OS can change this (TODO: Query OS default value)
|
||||
m_peerAddress = IpAddress::Invalid;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,14 +49,14 @@ namespace Nz
|
|||
|
||||
void TcpServer::OnClose()
|
||||
{
|
||||
TcpBase::OnClose();
|
||||
AbstractSocket::OnClose();
|
||||
|
||||
m_boundAddress = IpAddress::Invalid;
|
||||
}
|
||||
|
||||
void TcpServer::OnOpened()
|
||||
{
|
||||
TcpBase::OnOpened();
|
||||
AbstractSocket::OnOpened();
|
||||
|
||||
m_boundAddress = IpAddress::Invalid;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue