#include <Connection.h>
Inheritance diagram for Eris::Connection:
Public Member Functions | |
Connection (const std::string &cnm, bool debug) | |
Create a new connection, with the client-name string specified. | |
virtual void | connect (const std::string &host, short port=6767) |
If the underlying socket cannot be opened, Connect will throw an exception immediately. | |
void | reconnect () |
This will attempt reconnection to the server, providing a connection was completely established sucessfully before the error occurred. | |
void | disconnect () |
Initiate disconnection from the server. | |
Dispatcher * | getDispatcher () const |
get the root dispatcher for incoming messages | |
TypeService * | getTypeService () const |
Lobby * | getLobby () const |
Dispatcher * | getDispatcherByPath (const std::string &path) const |
Note that an invalid path specification will cause an exception to be thrown. | |
void | removeDispatcherByPath (const std::string &stem, const std::string &n) |
Remove a node from the dispatcher tree. | |
void | removeIfDispatcherByPath (const std::string &stem, const std::string &n) |
Remove the dispatch node iff found, otherwise do nothing. | |
virtual void | send (const Atlas::Objects::Root &obj) |
If the connection is not fully connected, an exception will be thrown. | |
virtual void | send (const Atlas::Message::Element &msg) |
The same comments regarding connection status and disconnect operation apply as above. | |
void | lock () |
Lock then connection's state. | |
void | unlock () |
Unlock the connection (permit status change). | |
Static Public Member Functions | |
Connection * | getPrimary () |
Connection * | Instance () |
deprecated | |
Public Attributes | |
SigC::Signal0< bool > | Disconnecting |
Emitted when the disconnection process is initiated. | |
SigC::Signal1< void, const std::string & > | Failure |
Emitted when a non-fatal error occurs; these are nearly always network related, such as connections being lost, or host names not found. | |
SigC::Signal1< void, Status > | Timeout |
Emitted when a network-level timeout occurs; the status code indicates in which stage of operation the timeout occurred. | |
SigC::Signal1< void, Status > | StatusChanged |
emitted when the connection status changes; This will often correspond to the emission of a more specific signal (such as Connected), which should be used where available. | |
Protected Member Functions | |
virtual void | setStatus (Status sc) |
update the connection status (and emit the appropriate signal) | |
virtual void | objectArrived (const Atlas::Message::Element &obj) |
objectArrived is the entry point for all data from the server into the client; notably, the message is forwarded to the root of the dispatcher tree and thus disseminated to all matching nodes. | |
virtual void | handleFailure (const std::string &msg) |
Process failures (to track when reconnection should be permitted). | |
virtual void | bindTimeout (Eris::Timeout &t, Status sc) |
virtual void | onConnect () |
derived-class notification when connection and negotiation is completed | |
void | postForDispatch (const Atlas::Message::Element &msg) |
this is how waitForBase gets it's payload back into the dispatch queue | |
void | addWait (WaitForBase *w) |
register a new WaitFor into the list | |
Protected Attributes | |
Dispatcher * | _rootDispatch |
the root of the dispatch tree | |
unsigned int | _statusLock |
locks connection to current state while > 0 | |
std::string | _host |
This is cleared if connection fails during establishment (i.e CONNECTING and NEGOTIATE states), to indicate that re-connection is not possible. | |
short | _port |
port of the server | |
bool | _debug |
Static Protected Attributes | |
Connection * | _theConnection = NULL |
static singleton instance | |
Friends | |
class | WaitForBase |
|
Create a new connection, with the client-name string specified. The client-name is sent during Atlas negotiation of the connection.
|
|
If the underlying socket cannot be opened, Connect will throw an exception immediately. Providing the basic connection is established, other failures will be reported via the Failure signal. Reimplemented from Eris::BaseConnection. |
|
get the root dispatcher for incoming messages Note the behaviour has changed since earlier versions of Eris; formerly it called select() internally to check for data (and hence was guranteed to be non-blocking. With the addition of the poll interface and PollDefault implementation, this call will now block if no data is pending on the connection. |
|
Note that an invalid path specification will cause an exception to be thrown. To access the root node, pass either an empty path or ":"; this is identical to calling GetDispatcher(). |
|
Lock then connection's state. This prevents the connection changing status until a corresponding unlock() call is issued. The only use at present is to hold the connection in the 'DISCONNECTING' state while other objects clean up and so on. In the future locking may also be applicable to other states. |
|
This will attempt reconnection to the server, providing a connection was completely established sucessfully before the error occurred. Otherwise, an exception will be thrown. This is prevent Reconnect being called on an invalid host, for example. |
|
Remove a node from the dispatcher tree. Throws InvalidOperation if path is invalid, or the the node is not found. |
|
If the connection is not fully connected, an exception will be thrown. To correctly handle disconnection, callers should therefore validate the connection using IsConnected first |
|
update the connection status (and emit the appropriate signal)
Reimplemented from Eris::BaseConnection. |
|
Unlock the connection (permit status change). See Connection::lock for more information about status locking. |
|
Emitted when a non-fatal error occurs; these are nearly always network related, such as connections being lost, or host names not found. The connection will be placed into the DISCONNECTED state after the signal is emitted; thus the current state (when the failure occured) is still valid during the callback |