1 #ifndef ERIS_BASE_CONNECTION_H
2 #define ERIS_BASE_CONNECTION_H
4 #include <Atlas/Objects/ObjectsFwd.h>
6 #include <sigc++/trackable.h>
7 #include <sigc++/signal.h>
11 class tcp_socket_stream;
38 virtual int connect(
const std::string &host,
short port);
71 const std::string&
getHost()
const;
90 BaseConnection(
const std::string &cnm,
const std::string &
id, Atlas::Bridge *br);
104 virtual void handleTimeout(
const std::string& msg) = 0;
106 void onConnectTimeout();
107 void onNegotiateTimeout();
120 Atlas::Net::StreamConnect*
_sc;
121 Atlas::Codec* m_codec;
tcp_socket_stream * _stream
the underlying iostream channel
Definition: BaseConnection.h:126
Atlas::Objects::ObjectsEncoder * _encode
the objects encoder, bound to _codec
Definition: BaseConnection.h:119
meta-query performing GET operation
Definition: BaseConnection.h:50
Status
possible states for the connection
Definition: BaseConnection.h:41
void recv()
perform a blocking read from the underlying socket
Definition: BaseConnection.cpp:156
void hardDisconnect(bool emit)
performs and instant disconnection from the server specified whether the change of state should be s...
Definition: BaseConnection.cpp:110
std::string _clientName
the client identified used during connection
Definition: BaseConnection.h:127
connection fully established
Definition: BaseConnection.h:45
Atlas::Net::StreamConnect * _sc
negotiation object (NULL after connection!)
Definition: BaseConnection.h:120
int getFileDescriptor()
get the underlyinmg file descriptor (socket).
Definition: BaseConnection.cpp:285
stream / socket connection in progress
Definition: BaseConnection.h:44
void pollNegotiation()
track negotation of the Atlas codecs / stream
Definition: BaseConnection.cpp:225
Status getStatus() const
get the current status of the connection
Definition: BaseConnection.h:54
Timeout * _timeout
network level timeouts
Definition: BaseConnection.h:132
clean disconnection in progress
Definition: BaseConnection.h:47
virtual ~BaseConnection()
destructor, will perform a hard disconnect if necessary
Definition: BaseConnection.cpp:69
virtual void handleFailure(const std::string &msg)=0
derived-class notification when a failure occurs
virtual void setStatus(Status sc)
update the connection status and generate signals
Definition: BaseConnection.cpp:280
const std::string & getHost() const
Gets the host of the connection.
Definition: BaseConnection.cpp:292
Definition: Account.cpp:35
finished disconnection
Definition: BaseConnection.h:46
virtual int connect(const std::string &host, short port)
open a connection to the specified host/port; invokes the failure handler if the connection could not...
Definition: BaseConnection.cpp:77
const std::string _id
a unique identifier for this connection
Definition: BaseConnection.h:124
Atlas::Bridge * _bridge
the connection bridge (i.e something implementing objectArrived()) : this can be the derived class it...
Definition: BaseConnection.h:131
BaseConnection(const std::string &cnm, const std::string &id, Atlas::Bridge *br)
create an unconnected instance
Definition: BaseConnection.cpp:44
sigc::signal< void > Connected
sent on successful negotiation of a game server connection
Definition: BaseConnection.h:81
Atlas negotiation in progress.
Definition: BaseConnection.h:43
Status _status
current status of the connection
Definition: BaseConnection.h:123
short _port
the port we're connected to
Definition: BaseConnection.h:135
Timeout.
Definition: Timeout.h:12
bool isConnected() const
Ascertain whether or not the connection is usable for transport.
Definition: BaseConnection.h:58
void nonblockingConnect()
complete the connection state and start negotiation
Definition: BaseConnection.cpp:193
short getPort() const
Gets the port of the connection.
Definition: BaseConnection.cpp:297
virtual void onConnect()
derived-class notification when connection and negotiation is completed
Definition: BaseConnection.cpp:260
std::string _host
the host name we're connected to
Definition: BaseConnection.h:134
Underlying Atlas connection, providing a send interface, and receive (dispatch) system.
Definition: BaseConnection.h:30
sigc::signal< void > Disconnected
final disconnect (or hard disocnnect) notifcation
Definition: BaseConnection.h:84
Definition: BaseConnection.h:13
indicates an illegal state
Definition: BaseConnection.h:42