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> 13 class stream_socket_stream;
40 virtual int connect(
const std::string &host,
short port);
45 virtual int connectLocal(
const std::string &socket);
66 {
return (_status == CONNECTED) || (_status == DISCONNECTING);}
71 int getFileDescriptor();
78 const std::string& getHost()
const;
85 short getPort()
const;
97 BaseConnection(
const std::string &cnm,
const std::string &
id, Atlas::Bridge *br);
103 virtual void setStatus(Status sc);
106 virtual void onConnect();
109 virtual void handleFailure(
const std::string &msg) = 0;
111 virtual void handleTimeout(
const std::string& msg) = 0;
113 void onConnectTimeout();
114 void onNegotiateTimeout();
118 void hardDisconnect(
bool emit);
121 void nonblockingConnect();
124 void pollNegotiation();
127 Atlas::Net::StreamConnect*
_sc;
128 Atlas::Codec* m_codec;
Atlas::Objects::ObjectsEncoder * _encode
the objects encoder, bound to _codec
Definition: BaseConnection.h:126
Status
possible states for the connection
Definition: BaseConnection.h:48
std::function< bool(void)> _is_ready_func
a method for calling "is_ready" on the stream, if such functionality is available ...
Definition: BaseConnection.h:135
std::function< int(void)> _open_next_func
a method for calling "open_next" on the stream, if such functionality is available ...
Definition: BaseConnection.h:134
std::string _clientName
the client identified used during connection
Definition: BaseConnection.h:137
connection fully established
Definition: BaseConnection.h:52
Atlas::Net::StreamConnect * _sc
negotiation object (NULL after connection!)
Definition: BaseConnection.h:127
stream / socket connection in progress
Definition: BaseConnection.h:51
Status getStatus() const
get the current status of the connection
Definition: BaseConnection.h:61
Timeout * _timeout
network level timeouts
Definition: BaseConnection.h:142
clean disconnection in progress
Definition: BaseConnection.h:54
Definition: Account.cpp:33
finished disconnection
Definition: BaseConnection.h:53
const std::string _id
a unique identifier for this connection
Definition: BaseConnection.h:131
Atlas::Bridge * _bridge
the connection bridge (i.e something implementing objectArrived()) : this can be the derived class it...
Definition: BaseConnection.h:141
sigc::signal< void > Connected
sent on successful negotiation of a game server connection
Definition: BaseConnection.h:88
Atlas negotiation in progress.
Definition: BaseConnection.h:50
Status _status
current status of the connection
Definition: BaseConnection.h:130
short _port
the port we're connected to
Definition: BaseConnection.h:145
Timeout.
Definition: Timeout.h:12
bool isConnected() const
Ascertain whether or not the connection is usable for transport.
Definition: BaseConnection.h:65
std::string _host
the host name we're connected to
Definition: BaseConnection.h:144
Underlying Atlas connection, providing a send interface, and receive (dispatch) system.
Definition: BaseConnection.h:32
sigc::signal< void > Disconnected
final disconnect (or hard disocnnect) notifcation
Definition: BaseConnection.h:91
stream_socket_stream * _stream
the underlying iostream channel
Definition: BaseConnection.h:133
Definition: BaseConnection.h:15