eris 1.4.0
A WorldForge client library.
Eris::ResolvableAsioStreamSocket< ProtocolT > Class Template Reference

Template specialization which uses boost::asio sockets with resolvers (i.e. TCP and UDP, but not domain sockets). More...

#include <StreamSocket.h>

Inheritance diagram for Eris::ResolvableAsioStreamSocket< ProtocolT >:
Collaboration diagram for Eris::ResolvableAsioStreamSocket< ProtocolT >:

Public Types

enum  Status {
  INVALID_STATUS = 0 , CONNECTING , CONNECTING_TIMEOUT , CONNECTING_FAILED ,
  NEGOTIATE , NEGOTIATE_TIMEOUT , NEGOTIATE_FAILED , CONNECTED ,
  CONNECTION_FAILED , DISCONNECTED , DISCONNECTING
}
 

Public Member Functions

 ResolvableAsioStreamSocket (boost::asio::io_service &io_service, const std::string &client_name, Atlas::Bridge &bridge, StreamSocket::Callbacks callbacks)
 
void connectWithQuery (const typename ProtocolT::resolver::query &query)
 
void connect (const typename ProtocolT::endpoint &endpoint)
 
void write () override
 Send any unsent data. More...
 
ProtocolT::socket & getAsioSocket ()
 
void detach ()
 Detaches the callbacks. More...
 
Atlas::Codec & getCodec ()
 Gets the codec object. More...
 
Atlas::Objects::ObjectsEncoder & getEncoder ()
 Gets the encoder object. More...
 

Protected Types

enum  { read_buffer_size = 2048 }
 

Protected Member Functions

void negotiate_read () override
 
void negotiate_write ()
 
void do_read () override
 
void startNegotiation ()
 
Atlas::Negotiate::State negotiate ()
 

Protected Attributes

ProtocolT::resolver m_resolver
 
ProtocolT::socket m_socket
 
boost::asio::io_service & m_io_service
 
Atlas::Bridge & _bridge
 
Callbacks _callbacks
 
std::unique_ptr< boost::asio::streambuf > mWriteBuffer
 
std::unique_ptr< boost::asio::streambuf > mSendBuffer
 
boost::asio::streambuf mReadBuffer
 
std::istream mInStream
 
std::ostream mOutStream
 
bool mShouldSend
 
bool mIsSending
 
std::unique_ptr< Atlas::Net::StreamConnect > _sc
 negotiation object (nullptr after connection!) More...
 
boost::asio::steady_timer _negotiateTimer
 
boost::asio::steady_timer _connectTimer
 
std::unique_ptr< Atlas::Codec > m_codec
 
std::unique_ptr< Atlas::Objects::ObjectsEncoder > m_encoder
 
bool m_is_connected
 

Detailed Description

template<typename ProtocolT>
class Eris::ResolvableAsioStreamSocket< ProtocolT >

Template specialization which uses boost::asio sockets with resolvers (i.e. TCP and UDP, but not domain sockets).

Definition at line 205 of file StreamSocket.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protectedinherited

Definition at line 121 of file StreamSocket.h.

◆ Status

Enumerator
INVALID_STATUS 

indicates an illegal state

CONNECTING 

stream / socket connection in progress

CONNECTING_TIMEOUT 

timeout when trying to establish a connection

CONNECTING_FAILED 

failure when trying to establish a connection

NEGOTIATE 

Atlas negotiation in progress.

NEGOTIATE_TIMEOUT 

timeout when negotiating

NEGOTIATE_FAILED 

failure when negotiating

CONNECTED 

connection fully established

CONNECTION_FAILED 

connection failed

DISCONNECTED 

finished disconnection

DISCONNECTING 

clean disconnection in progress

Definition at line 58 of file StreamSocket.h.

Constructor & Destructor Documentation

◆ ResolvableAsioStreamSocket()

template<typename ProtocolT >
Eris::ResolvableAsioStreamSocket< ProtocolT >::ResolvableAsioStreamSocket ( boost::asio::io_service &  io_service,
const std::string &  client_name,
Atlas::Bridge &  bridge,
StreamSocket::Callbacks  callbacks 
)

Definition at line 70 of file StreamSocket_impl.h.

Member Function Documentation

◆ connect()

template<typename ProtocolT >
void Eris::AsioStreamSocket< ProtocolT >::connect ( const typename ProtocolT::endpoint &  endpoint)
inherited

Definition at line 98 of file StreamSocket_impl.h.

◆ connectWithQuery()

template<typename ProtocolT >
void Eris::ResolvableAsioStreamSocket< ProtocolT >::connectWithQuery ( const typename ProtocolT::resolver::query &  query)

Definition at line 81 of file StreamSocket_impl.h.

◆ detach()

void Eris::StreamSocket::detach ( )
inherited

Detaches the callbacks.

Call this when the owner instance is destroyed, or you otherwise don't want any callbacks.

Definition at line 58 of file StreamSocket.cpp.

◆ do_read()

template<typename ProtocolT >
void Eris::AsioStreamSocket< ProtocolT >::do_read
overrideprotectedvirtualinherited

Implements Eris::StreamSocket.

Definition at line 166 of file StreamSocket_impl.h.

◆ getAsioSocket()

template<typename ProtocolT >
ProtocolT::socket & Eris::AsioStreamSocket< ProtocolT >::getAsioSocket
inherited

Definition at line 64 of file StreamSocket_impl.h.

◆ getCodec()

Atlas::Codec & Eris::StreamSocket::getCodec ( )
inherited

Gets the codec object.

Note
Only call this after the socket has successfully negotiated.
Returns

Definition at line 123 of file StreamSocket.cpp.

◆ getEncoder()

Atlas::Objects::ObjectsEncoder & Eris::StreamSocket::getEncoder ( )
inherited

Gets the encoder object.

Note
Only call this after the socket has successfully negotiated.
Returns

Definition at line 128 of file StreamSocket.cpp.

◆ negotiate()

Atlas::Negotiate::State Eris::StreamSocket::negotiate ( )
protectedinherited

Definition at line 86 of file StreamSocket.cpp.

◆ negotiate_read()

template<typename ProtocolT >
void Eris::AsioStreamSocket< ProtocolT >::negotiate_read
overrideprotectedvirtualinherited

Implements Eris::StreamSocket.

Definition at line 127 of file StreamSocket_impl.h.

◆ negotiate_write()

template<typename ProtocolT >
void Eris::AsioStreamSocket< ProtocolT >::negotiate_write
protectedinherited

Definition at line 235 of file StreamSocket_impl.h.

◆ startNegotiation()

void Eris::StreamSocket::startNegotiation ( )
protectedinherited

Definition at line 62 of file StreamSocket.cpp.

◆ write()

template<typename ProtocolT >
void Eris::AsioStreamSocket< ProtocolT >::write ( )
overridevirtualinherited

Send any unsent data.

Implements Eris::StreamSocket.

Definition at line 191 of file StreamSocket_impl.h.

Member Data Documentation

◆ _bridge

Atlas::Bridge& Eris::StreamSocket::_bridge
protectedinherited

Definition at line 126 of file StreamSocket.h.

◆ _callbacks

Callbacks Eris::StreamSocket::_callbacks
protectedinherited

Definition at line 127 of file StreamSocket.h.

◆ _connectTimer

boost::asio::steady_timer Eris::StreamSocket::_connectTimer
protectedinherited

Definition at line 168 of file StreamSocket.h.

◆ _negotiateTimer

boost::asio::steady_timer Eris::StreamSocket::_negotiateTimer
protectedinherited

Definition at line 167 of file StreamSocket.h.

◆ _sc

std::unique_ptr<Atlas::Net::StreamConnect> Eris::StreamSocket::_sc
protectedinherited

negotiation object (nullptr after connection!)

Definition at line 166 of file StreamSocket.h.

◆ m_codec

std::unique_ptr<Atlas::Codec> Eris::StreamSocket::m_codec
protectedinherited

Definition at line 169 of file StreamSocket.h.

◆ m_encoder

std::unique_ptr<Atlas::Objects::ObjectsEncoder> Eris::StreamSocket::m_encoder
protectedinherited

Definition at line 170 of file StreamSocket.h.

◆ m_io_service

boost::asio::io_service& Eris::StreamSocket::m_io_service
protectedinherited

Definition at line 125 of file StreamSocket.h.

◆ m_is_connected

bool Eris::StreamSocket::m_is_connected
protectedinherited

Definition at line 171 of file StreamSocket.h.

◆ m_resolver

template<typename ProtocolT >
ProtocolT::resolver Eris::ResolvableAsioStreamSocket< ProtocolT >::m_resolver
protected

Definition at line 213 of file StreamSocket.h.

◆ m_socket

template<typename ProtocolT >
ProtocolT::socket Eris::AsioStreamSocket< ProtocolT >::m_socket
protectedinherited

Definition at line 195 of file StreamSocket.h.

◆ mInStream

std::istream Eris::StreamSocket::mInStream
protectedinherited

Stream for data being received.

Definition at line 149 of file StreamSocket.h.

◆ mIsSending

bool Eris::StreamSocket::mIsSending
protectedinherited

True if we're currently sending through an async_write (and thus shouldn't touch mSendBuffer).

Definition at line 164 of file StreamSocket.h.

◆ mOutStream

std::ostream Eris::StreamSocket::mOutStream
protectedinherited

Stream for data being sent out.

Definition at line 154 of file StreamSocket.h.

◆ mReadBuffer

boost::asio::streambuf Eris::StreamSocket::mReadBuffer
protectedinherited

Buffer for data being read from the socket.

Definition at line 144 of file StreamSocket.h.

◆ mSendBuffer

std::unique_ptr<boost::asio::streambuf> Eris::StreamSocket::mSendBuffer
protectedinherited

Buffer of data which is being sent. This should not be touched until the async_write call completes.

Definition at line 139 of file StreamSocket.h.

◆ mShouldSend

bool Eris::StreamSocket::mShouldSend
protectedinherited

True if we should send again as soon as an ongoing async_write operation completes.

Definition at line 159 of file StreamSocket.h.

◆ mWriteBuffer

std::unique_ptr<boost::asio::streambuf> Eris::StreamSocket::mWriteBuffer
protectedinherited

Buffer used to write data to be sent. Swapped with mSendBuffer once data is being sent.

Definition at line 133 of file StreamSocket.h.


The documentation for this class was generated from the following files: