Documentation for module: Network

Former-commit-id: 0563349542b717b602d5a6eb7728bd40b2af7e1f
This commit is contained in:
Gawaboumga
2016-05-30 14:22:31 +02:00
parent 2c941827ed
commit 36c1ef1b97
25 changed files with 1368 additions and 25 deletions

View File

@@ -17,6 +17,18 @@
namespace Nz
{
/*!
* \ingroup network
* \class Nz::AbstractSocket
* \brief Network class that represents the base of socket
*
* \remark This class is abstract
*/
/*!
* \brief Constructs a AbstractSocket object with a type
*/
AbstractSocket::AbstractSocket(SocketType type) :
m_lastError(SocketError_NoError),
m_handle(SocketImpl::InvalidHandle),
@@ -26,6 +38,12 @@ namespace Nz
{
}
/*!
* \brief Constructs a AbstractSocket object with another one by move semantic
*
* \param abstractSocket AbstractSocket to move into this
*/
AbstractSocket::AbstractSocket(AbstractSocket&& abstractSocket) :
m_protocol(abstractSocket.m_protocol),
m_lastError(abstractSocket.m_lastError),
@@ -37,11 +55,21 @@ namespace Nz
abstractSocket.m_handle = SocketImpl::InvalidHandle;
}
/*!
* \brief Destructs the object and calls Close
*
* \see Close
*/
AbstractSocket::~AbstractSocket()
{
Close();
}
/*!
* \brief Closes the socket
*/
void AbstractSocket::Close()
{
if (m_handle != SocketImpl::InvalidHandle)
@@ -53,6 +81,12 @@ namespace Nz
}
}
/*!
* \brief Enables blocking
*
* \param blocking Should the read block
*/
void AbstractSocket::EnableBlocking(bool blocking)
{
if (m_isBlockingEnabled != blocking)
@@ -64,6 +98,11 @@ namespace Nz
}
}
/*!
* \brief Queries the available bytes
* \return Number of bytes which can be read
*/
std::size_t AbstractSocket::QueryAvailableBytes() const
{
if (m_handle == SocketImpl::InvalidHandle)
@@ -72,11 +111,21 @@ namespace Nz
return SocketImpl::QueryAvailableBytes(m_handle);
}
/*!
* \brief Operation to do when closing socket
*/
void AbstractSocket::OnClose()
{
UpdateState(SocketState_NotConnected);
}
/*!
* \brief Operation to do when opening socket
*
* \remark Produces a NazaraWarning if blocking failed
*/
void AbstractSocket::OnOpened()
{
SocketError errorCode;
@@ -84,6 +133,11 @@ namespace Nz
NazaraWarning("Failed to set socket blocking mode (0x" + String::Number(errorCode, 16) + ')');
}
/*!
* \brief Opens the socket according to a net protocol
* \return true If successful
*/
bool AbstractSocket::Open(NetProtocol protocol)
{
if (m_handle == SocketImpl::InvalidHandle || m_protocol != protocol)
@@ -99,6 +153,13 @@ namespace Nz
return true;
}
/*!
* \brief Opens the socket according to a socket handle
* \return true If successful
*
* \remark Produces a NazaraAssert if handle is invalid
*/
void AbstractSocket::Open(SocketHandle handle)
{
NazaraAssert(handle != SocketImpl::InvalidHandle, "Invalid handle");
@@ -109,6 +170,13 @@ namespace Nz
OnOpened();
}
/*!
* \brief Moves the AbstractSocket into this
* \return A reference to this
*
* \param abstractSocket AbstractSocket to move in this
*/
AbstractSocket& AbstractSocket::operator=(AbstractSocket&& abstractSocket)
{
Close();