17 #ifndef ENDPOINTREGISTRATIONMANAGER_HPP_
18 #define ENDPOINTREGISTRATIONMANAGER_HPP_
41 class UserAttachRequest;
42 class IAttachedEndpointListListener;
44 class EndpointRegistrationManager :
public IEndpointRegistrationManager
45 ,
public IRegistrationProcessor
50 virtual void regenerateEndpointAccessToken();
52 virtual const std::string& getEndpointAccessToken() {
53 return endpointAccessToken_;
56 virtual void attachEndpoint(
const std::string& endpointAccessToken
57 , IEndpointAttachStatusListener* listener =
nullptr);
59 virtual void detachEndpoint(
const std::string& endpointKeyHash
60 , IEndpointAttachStatusListener* listener =
nullptr);
62 virtual void detachEndpoint(IEndpointAttachStatusListener* listener =
nullptr);
64 virtual void attachUser(
const std::string& userExternalId
65 ,
const std::string& userAccessToken
66 , IEndpointAttachStatusListener* listener =
nullptr);
70 virtual void addAttachedEndpointListListener(IAttachedEndpointListListener *listener);
72 virtual void removeAttachedEndpointListListener(IAttachedEndpointListListener *listener);
74 virtual std::map<std::int32_t, std::string> getEndpointsToAttach();
75 virtual std::map<std::int32_t, std::string> getEndpointsToDetach();
76 virtual UserAttachRequestPtr getUserAttachRequest();
78 virtual void onUserAttach(
const UserSyncResponse::userAttachResponse_t& response);
80 virtual void onEndpointsAttach(
const std::vector<EndpointAttachResponse>& endpoints);
81 virtual void onEndpointsDetach(
const std::vector<EndpointDetachResponse>& endpoints);
83 virtual void onCurrentEndpointAttach(
const UserAttachNotification& response);
84 virtual void onCurrentEndpointDetach(
const UserDetachNotification& response);
86 virtual bool isCurrentEndpointAttached() {
87 return status_->getEndpointAttachStatus();
90 virtual void setTransport(UserTransport * transport) {
91 userTransport_ = transport;
92 if (userTransport_ !=
nullptr && (userAttachRequest_.get() !=
nullptr || !attachingEndpoints_.empty() || !detachingEndpoints_.empty())) {
93 userTransport_->sync();
97 virtual void setAttachStatusListener(IEndpointAttachStatusListener* listener) {
98 if (listener !=
nullptr) {
99 attachStatusListener_ = listener;
104 void onEndpointAccessTokenChanged(
const std::string& old);
107 struct EndpointOperationInfo {
108 std::string endpointData_;
109 IEndpointAttachStatusListener* listener_;
116 std::string endpointAccessToken_;
117 std::string endpointKeyHash_;
119 UserAttachRequestPtr userAttachRequest_;
121 std::map<std::int32_t, EndpointOperationInfo> attachingEndpoints_;
122 std::map<std::int32_t, EndpointOperationInfo> detachingEndpoints_;
123 std::map<std::string, std::string> attachedEndpoints_;
126 UserTransport * userTransport_;
128 KaaObservable<void (const AttachedEndpoints&), IAttachedEndpointListListener *> attachedEPListListeners_;
131 IEndpointAttachStatusListener* attachStatusListener_;
std::map< std::string, std::string > AttachedEndpoints
#define KAA_R_MUTEX_DECLARE(name)
std::shared_ptr< IKaaClientStateStorage > IKaaClientStateStoragePtr