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;