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>
32 class ResponseTracker;
42 struct ConnectionDecoder;
53 Connection(boost::asio::io_service& io_service,
55 std::string clientName,
56 const std::string& host,
63 Connection(boost::asio::io_service& io_service,
65 std::string clientName,
78 TypeService& getTypeService()
const {
return *m_typeService; }
88 virtual void send(
const Atlas::Objects::Root& obj);
90 void setDefaultRouter(
Router* router);
92 void clearDefaultRouter();
94 void registerRouterForTo(
Router* router,
const std::string& toId);
96 void unregisterRouterForTo(
Router* router,
const std::string& toId);
98 void registerRouterForFrom(
Router* router,
const std::string& fromId);
100 void unregisterRouterForFrom(
const std::string& fromId);
127 sigc::signal<void> GotServerInfo;
142 sigc::signal<void, const std::string&>
Failure;
158 void handleTimeout(
const std::string& msg)
override;
162 virtual void objectArrived(Atlas::Objects::Root obj);
164 std::unique_ptr<ConnectionDecoder> m_decoder;
168 const std::string _host;
170 const std::string _localSocket;
174 friend class TestInjector;
182 void dispatch()
override;
184 void dispatchOp(
const Atlas::Objects::Operation::RootOperation& op);
186 void handleServerInfo(
const Atlas::Objects::Operation::RootOperation& op);
188 void onDisconnectTimeout();
190 typedef std::deque<Atlas::Objects::Operation::RootOperation> OpDeque;
193 std::unique_ptr<TypeService> m_typeService;
196 typedef std::unordered_map<std::string, Router*> IdRouterMap;
197 IdRouterMap m_toRouters;
198 IdRouterMap m_fromRouters;
202 std::vector<std::unique_ptr<Redispatch>> m_finishedRedispatches;
205 std::unique_ptr<ResponseTracker> m_responder;
Underlying Atlas connection, providing a send interface, and receive (dispatch) system.
Status
possible states for the connection
sigc::signal< bool > Disconnecting
int disconnect()
Initiate disconnection from the server.
void handleFailure(const std::string &msg) override
Process failures (to track when reconnection should be permitted)
sigc::signal< void, Status > StatusChanged
indicates a status change on the connection
virtual void send(const Atlas::Objects::Root &obj)
Transmit an Atlas::Objects instance to the server.
void postForDispatch(const Atlas::Objects::Root &obj)
void onConnect() override
derived-class notification when connection and negotiation is completed
void setStatus(Status sc) override
Connection(boost::asio::io_service &io_service, EventService &eventService, std::string clientName, const std::string &host, short port)
Create an unconnected instance.
sigc::signal< void, const std::string & > Failure
void getServerInfo(ServerInfo &) const
const short _port
port of the server
OpDeque m_opDeque
store of all the received ops waiting to be dispatched
Handles polling of the IO system as well as making sure that registered handlers are run on the main ...
std::int64_t getNewSerialno()
operation serial number sequencing