1 #ifndef ERIS_CONNECTION_H 2 #define ERIS_CONNECTION_H 4 #include "BaseConnection.h" 5 #include "ServerInfo.h" 7 #include <Atlas/Objects/Decoder.h> 8 #include <Atlas/Objects/ObjectsFwd.h> 9 #include <Atlas/Objects/RootOperation.h> 13 #include <unordered_map> 28 class ResponseTracker;
38 public Atlas::Objects::ObjectsDecoder
46 Connection(boost::asio::io_service& io_service,
EventService& eventService,
const std::string &cnm,
const std::string& host,
short port);
52 Connection(boost::asio::io_service& io_service,
EventService& eventService,
const std::string &cnm,
const std::string& socket);
65 {
return m_typeService.get(); }
68 {
return m_responder.get(); }
76 virtual void send(
const Atlas::Objects::Root &obj);
78 void setDefaultRouter(
Router* router);
80 void clearDefaultRouter();
82 void registerRouterForTo(
Router* router,
const std::string& toId);
83 void unregisterRouterForTo(
Router* router,
const std::string& toId);
85 void registerRouterForFrom(
Router* router,
const std::string& fromId);
86 void unregisterRouterForFrom(
Router* router,
const std::string& fromId);
113 sigc::signal<void> GotServerInfo;
128 sigc::signal<void, const std::string&>
Failure;
144 void handleTimeout(
const std::string& msg)
override;
148 void objectArrived(
const Atlas::Objects::Root& obj)
override;
152 const std::string _host;
154 const std::string _localSocket;
157 friend class TestInjector;
165 void dispatch()
override;
167 void dispatchOp(
const Atlas::Objects::Operation::RootOperation& op);
168 void handleServerInfo(
const Atlas::Objects::Operation::RootOperation& op);
170 void onDisconnectTimeout();
172 typedef std::deque<Atlas::Objects::Operation::RootOperation> OpDeque;
175 std::unique_ptr<TypeService> m_typeService;
178 typedef std::unordered_map<std::string, Router*> IdRouterMap;
179 IdRouterMap m_toRouters;
180 IdRouterMap m_fromRouters;
184 std::vector<Redispatch*> m_finishedRedispatches;
187 std::unique_ptr<ResponseTracker> m_responder;
void onConnect() override
derived-class notification when connection and negotiation is completed
Definition: Connection.cpp:353
Definition: Redispatch.h:17
void setStatus(Status sc) override
update the connection status (and emit the appropriate signal)
Definition: Connection.cpp:323
Status
possible states for the connection
Definition: BaseConnection.h:52
void handleFailure(const std::string &msg) override
Process failures (to track when reconnection should be permitted)
Definition: Connection.cpp:329
Information about a specific game server, retrieved via the Meta-server and anonymous GETs...
Definition: ServerInfo.h:22
int disconnect()
Initiate disconnection from the server.
Definition: Connection.cpp:86
void postForDispatch(const Atlas::Objects::Root &obj)
Inject a local operation into the dispatch queue.
Definition: Connection.cpp:366
OpDeque m_opDeque
store of all the received ops waiting to be dispatched
Definition: Connection.h:173
Connection(boost::asio::io_service &io_service, EventService &eventService, const std::string &cnm, const std::string &host, short port)
Create an unconnected instance.
Definition: Connection.cpp:35
sigc::signal< bool > Disconnecting
Emitted when the disconnection process is initiated.
Definition: Connection.h:120
long getNewSerialno()
operation serial number sequencing
Definition: Connection.cpp:388
Every Eris class and type lives inside the Eris namespace; certain utility functions live in the Util...
Definition: Account.cpp:34
void unlock()
Unlock the connection (permit status change).
Definition: Connection.cpp:217
Underlying Atlas connection, providing a send interface, and receive (dispatch) system.
Definition: Connection.h:36
Handles polling of the IO system as well as making sure that registered handlers are run on the main ...
Definition: EventService.h:43
virtual void send(const Atlas::Objects::Root &obj)
Transmit an Atlas::Objects instance to the server.
Definition: Connection.cpp:147
sigc::signal< void, Status > StatusChanged
indicates a status change on the connection
Definition: Connection.h:134
const short _port
port of the server
Definition: Connection.h:153
int connect()
If the underlying socket cannot be opened, connect will return an error number immediately.
Definition: Connection.cpp:76
A service class querying and caching types.
Definition: TypeService.h:24
Definition: Response.h:61
sigc::signal< void, const std::string & > Failure
Emitted when a non-fatal error occurs.
Definition: Connection.h:128
void refreshServerInfo()
Update the information stored about the current server.
Definition: Connection.cpp:245
Underlying Atlas connection, providing a send interface, and receive (dispatch) system.
Definition: BaseConnection.h:36
void lock()
Lock then connection's state.
Definition: Connection.cpp:212
abstract interface for objects that can route Atlas data.
Definition: Router.h:10
void getServerInfo(ServerInfo &) const
Retrive the current server information.
Definition: Connection.cpp:240