eris 1.4.0
A WorldForge client library.
|
Underlying Atlas connection, providing a send interface, and receive (dispatch) system. More...
#include <BaseConnection.h>
Public Types | |
enum | Status { INVALID_STATUS = 0 , NEGOTIATE , CONNECTING , CONNECTED , DISCONNECTED , DISCONNECTING , QUERY_GET } |
possible states for the connection More... | |
Public Member Functions | |
virtual | ~BaseConnection () |
destructor, will perform a hard disconnect if necessary More... | |
virtual int | connectRemote (const std::string &host, short port) |
virtual int | connectLocal (const std::string &socket) |
Status | getStatus () const |
get the current status of the connection More... | |
bool | isConnected () const |
Ascertain whether or not the connection is usable for transport. More... | |
const std::string & | getHost () const |
short | getPort () const |
Atlas::Objects::Factories & | getFactories () |
const Atlas::Objects::Factories & | getFactories () const |
Public Attributes | |
sigc::signal< void > | Connected |
sent on successful negotiation of a game server connection More... | |
sigc::signal< void > | Disconnected |
final disconnect (or hard disocnnect) notifcation More... | |
Protected Member Functions | |
BaseConnection (boost::asio::io_service &io_service, std::string clientName, std::string id) | |
create an unconnected instance More... | |
void | stateChanged (StreamSocket::Status status) |
virtual void | setStatus (Status sc) |
update the connection status and generate signals More... | |
virtual void | onConnect () |
derived-class notification when connection and negotiation is completed More... | |
virtual void | handleFailure (const std::string &msg)=0 |
derived-class notification when a failure occurs More... | |
virtual void | handleTimeout (const std::string &msg)=0 |
virtual void | dispatch ()=0 |
void | onConnectTimeout () |
void | onNegotiateTimeout () |
void | hardDisconnect (bool emit) |
Protected Attributes | |
boost::asio::io_service & | _io_service |
std::unique_ptr< Atlas::Objects::Factories > | _factories |
std::shared_ptr< StreamSocket > | _socket |
Status | _status |
current status of the connection More... | |
const std::string | _id |
a unique identifier for this connection More... | |
std::string | _clientName |
the client identified used during connection More... | |
Atlas::Bridge * | _bridge |
std::string | _host |
the host name we're connected to More... | |
short | _port |
the port we're connected to More... | |
Underlying Atlas connection, providing a send interface, and receive (dispatch) system.
Definition at line 39 of file BaseConnection.h.
possible states for the connection
Definition at line 55 of file BaseConnection.h.
|
virtual |
destructor, will perform a hard disconnect if necessary
Definition at line 54 of file BaseConnection.cpp.
References _status, DISCONNECTED, and hardDisconnect().
|
protected |
create an unconnected instance
Create a new connection, with the client-name string specified. The client-name is sent during Atlas negotiation of the connection. Id is a unique string to identify timeouts created by the connection (and potentially errors in the future)
Definition at line 38 of file BaseConnection.cpp.
|
virtual |
Try to connect to a local socket.
Definition at line 98 of file BaseConnection.cpp.
References _bridge, _clientName, CONNECTING, Eris::StreamSocket::Callbacks::dispatch, hardDisconnect(), setStatus(), and Eris::StreamSocket::Callbacks::stateChanged.
Referenced by Eris::Connection::connect().
|
virtual |
open a connection to the specified host/port; invokes the failure handler if the connection could not be opened.
Definition at line 65 of file BaseConnection.cpp.
References _bridge, _clientName, CONNECTING, Eris::StreamSocket::Callbacks::dispatch, hardDisconnect(), Eris::StreamSocket::NEGOTIATE, setStatus(), and Eris::StreamSocket::Callbacks::stateChanged.
Referenced by Eris::Connection::connect().
Atlas::Objects::Factories & Eris::BaseConnection::getFactories | ( | ) |
Definition at line 213 of file BaseConnection.cpp.
const Atlas::Objects::Factories & Eris::BaseConnection::getFactories | ( | ) | const |
Definition at line 217 of file BaseConnection.cpp.
const std::string & Eris::BaseConnection::getHost | ( | ) | const |
Gets the host of the connection.
Definition at line 203 of file BaseConnection.cpp.
References _host.
short Eris::BaseConnection::getPort | ( | ) | const |
Gets the port of the connection.
Definition at line 208 of file BaseConnection.cpp.
References _port.
|
inline |
get the current status of the connection
Definition at line 68 of file BaseConnection.h.
References _status.
|
protectedpure virtual |
derived-class notification when a failure occurs
Implemented in Eris::Connection, and Eris::MetaQuery.
|
protected |
performs and instant disconnection from the server @emit specified whether the change of state should be signalled
Definition at line 162 of file BaseConnection.cpp.
References _status, DISCONNECTED, Disconnected, and setStatus().
Referenced by connectLocal(), connectRemote(), Eris::Connection::disconnect(), Eris::Connection::send(), Eris::Connection::unlock(), and ~BaseConnection().
|
inline |
Ascertain whether or not the connection is usable for transport.
Definition at line 72 of file BaseConnection.h.
References _status, CONNECTED, and DISCONNECTING.
Referenced by Eris::Room::createRoom(), Eris::Room::emote(), Eris::Room::leave(), Eris::Account::login(), Eris::Account::logout(), Eris::Person::msg(), Eris::Account::refreshCharacterInfo(), Eris::Room::say(), Eris::Account::takeCharacter(), and Eris::Account::takeTransferredCharacter().
|
protectedvirtual |
derived-class notification when connection and negotiation is completed
Reimplemented in Eris::Connection, and Eris::MetaQuery.
Definition at line 178 of file BaseConnection.cpp.
References Connected.
Referenced by Eris::Connection::onConnect().
|
protected |
Definition at line 184 of file BaseConnection.cpp.
|
protected |
Definition at line 192 of file BaseConnection.cpp.
|
protectedvirtual |
update the connection status and generate signals
Reimplemented in Eris::Connection.
Definition at line 198 of file BaseConnection.cpp.
References _status.
Referenced by connectLocal(), connectRemote(), and hardDisconnect().
|
protected |
Definition at line 125 of file BaseConnection.cpp.
|
protected |
the connection bridge (i.e something implementing objectArrived()) : this can be the derived class itself, or any other object
Definition at line 139 of file BaseConnection.h.
Referenced by Eris::Connection::Connection(), connectLocal(), and connectRemote().
|
protected |
the client identified used during connection
Definition at line 135 of file BaseConnection.h.
Referenced by connectLocal(), and connectRemote().
|
protected |
Definition at line 129 of file BaseConnection.h.
|
protected |
the host name we're connected to
Definition at line 141 of file BaseConnection.h.
Referenced by getHost().
|
protected |
a unique identifier for this connection
Definition at line 133 of file BaseConnection.h.
|
protected |
Definition at line 128 of file BaseConnection.h.
|
protected |
the port we're connected to
Definition at line 142 of file BaseConnection.h.
Referenced by getPort().
|
protected |
Definition at line 130 of file BaseConnection.h.
|
protected |
current status of the connection
Definition at line 132 of file BaseConnection.h.
Referenced by Eris::Connection::disconnect(), getStatus(), hardDisconnect(), isConnected(), Eris::Connection::refreshServerInfo(), Eris::Connection::send(), setStatus(), Eris::Connection::setStatus(), Eris::Connection::unlock(), and ~BaseConnection().
sigc::signal<void> Eris::BaseConnection::Connected |
sent on successful negotiation of a game server connection
Definition at line 95 of file BaseConnection.h.
Referenced by Eris::Account::Account(), and onConnect().
sigc::signal<void> Eris::BaseConnection::Disconnected |
final disconnect (or hard disocnnect) notifcation
Definition at line 98 of file BaseConnection.h.
Referenced by hardDisconnect().