Eris  1.4.0
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Eris::StreamSocket Class Referenceabstract

Handles the internal socket instance, interacting with the asynchronous io_service calls. More...

#include <StreamSocket.h>

Inheritance diagram for Eris::StreamSocket:
Eris::AsioStreamSocket< ProtocolT > Eris::ResolvableAsioStreamSocket< ProtocolT >

Classes

struct  Callbacks
 Methods that are used as callbacks. More...
 

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

 StreamSocket (boost::asio::io_service &io_service, const std::string &client_name, Atlas::Bridge &bridge, Callbacks &callbacks)
 
void detach ()
 Detaches the callbacks. More...
 
Atlas::Codec & getCodec ()
 Gets the codec object. More...
 
Atlas::Objects::ObjectsEncoder & getEncoder ()
 Gets the encoder object. More...
 
virtual void write ()=0
 Send any unsent data.
 

Protected Types

enum  { read_buffer_size = 2048 }
 

Protected Member Functions

virtual void do_read ()=0
 
virtual void negotiate_read ()=0
 
void startNegotiation ()
 
Atlas::Negotiate::State negotiate ()
 

Protected Attributes

boost::asio::io_service & m_io_service
 
Atlas::Bridge & _bridge
 
Callbacks _callbacks
 
boost::asio::streambuf * mWriteBuffer
 Buffer used to write data to be sent. More...
 
boost::asio::streambuf * mSendBuffer
 Buffer of data which is being sent. More...
 
boost::asio::streambuf mReadBuffer
 Buffer for data being read from the socket.
 
std::istream mInStream
 Stream for data being received.
 
std::ostream mOutStream
 Stream for data being sent out.
 
bool mShouldSend
 True if we should send again as soon as an ongoing async_write operation completes.
 
bool mIsSending
 True if we're currently sending through an async_write (and thus shouldn't touch mSendBuffer).
 
Atlas::Net::StreamConnect * _sc
 negotiation object (NULL after connection!)
 
boost::asio::deadline_timer _negotiateTimer
 
boost::asio::deadline_timer _connectTimer
 
Atlas::Codec * m_codec
 
Atlas::Objects::ObjectsEncoder * m_encoder
 
bool m_is_connected
 

Detailed Description

Handles the internal socket instance, interacting with the asynchronous io_service calls.

Since this will be used to make asynchronous calls it must be wrapped in a shared_ptr. When the owner instance is destroyed it must call "detach" to make sure the connection is severed.

Member Enumeration Documentation

◆ 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

Member Function Documentation

◆ detach()

void Eris::StreamSocket::detach ( )

Detaches the callbacks.

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

◆ getCodec()

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

Gets the codec object.

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

◆ getEncoder()

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

Gets the encoder object.

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

Member Data Documentation

◆ mSendBuffer

boost::asio::streambuf* Eris::StreamSocket::mSendBuffer
protected

Buffer of data which is being sent.

This should not be touched until the async_write call completes.

Referenced by Eris::AsioStreamSocket< ProtocolT >::write().

◆ mWriteBuffer

boost::asio::streambuf* Eris::StreamSocket::mWriteBuffer
protected

Buffer used to write data to be sent.

Swapped with mSendBuffer once data is being sent.

Referenced by Eris::AsioStreamSocket< ProtocolT >::write().


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