eris
1.4.0
A WorldForge client library.
|
Handles the internal socket instance, interacting with the asynchronous io_service calls. More...
#include <StreamSocket.h>
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. More... | |
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 |
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 |
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.
Definition at line 54 of file StreamSocket.h.
Definition at line 58 of file StreamSocket.h.
void Eris::StreamSocket::detach | ( | ) |
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.
Atlas::Codec & Eris::StreamSocket::getCodec | ( | ) |
Gets the codec object.
Definition at line 123 of file StreamSocket.cpp.
Atlas::Objects::ObjectsEncoder & Eris::StreamSocket::getEncoder | ( | ) |
Gets the encoder object.
Definition at line 128 of file StreamSocket.cpp.
|
pure virtual |
Send any unsent data.
Implemented in Eris::AsioStreamSocket< ProtocolT >.
|
protected |
negotiation object (nullptr after connection!)
Definition at line 166 of file StreamSocket.h.
|
protected |
Stream for data being received.
Definition at line 149 of file StreamSocket.h.
|
protected |
True if we're currently sending through an async_write (and thus shouldn't touch mSendBuffer).
Definition at line 164 of file StreamSocket.h.
|
protected |
Stream for data being sent out.
Definition at line 154 of file StreamSocket.h.
|
protected |
Buffer for data being read from the socket.
Definition at line 144 of file StreamSocket.h.
|
protected |
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.
|
protected |
True if we should send again as soon as an ongoing async_write operation completes.
Definition at line 159 of file StreamSocket.h.
|
protected |
Buffer used to write data to be sent. Swapped with mSendBuffer once data is being sent.
Definition at line 133 of file StreamSocket.h.