// // Copyright (c) ZeroC, Inc. All rights reserved. // #ifndef GLACIER2_SESSION_ROUTER_I_H #define GLACIER2_SESSION_ROUTER_I_H #include #include #include #include #include namespace Glacier2 { class FilterManager; class Instance; class RouterI; class SessionRouterI; class SSLCreateSession; class UserPasswordCreateSession; class CreateSession : public std::enable_shared_from_this { public: CreateSession(std::shared_ptr, const std::string&, const Ice::Current&); void create(); void addPendingCallback(std::shared_ptr); void authorized(bool); void unexpectedAuthorizeException(std::exception_ptr); void sessionCreated(const std::shared_ptr&); void unexpectedCreateSessionException(std::exception_ptr); void exception(std::exception_ptr); void createException(std::exception_ptr); virtual void authorize() = 0; virtual void createSession() = 0; virtual std::shared_ptr createFilterManager() = 0; virtual void finished(const std::shared_ptr&) = 0; virtual void finished(std::exception_ptr) = 0; protected: const std::shared_ptr _instance; const std::shared_ptr _sessionRouter; const std::string _user; const Ice::Current _current; Ice::Context _context; std::vector> _pendingCallbacks; std::shared_ptr _control; std::shared_ptr _filterManager; }; class SessionRouterI final : public Router, public Glacier2::Instrumentation::ObserverUpdater, public std::enable_shared_from_this { public: SessionRouterI(std::shared_ptr, std::shared_ptr, std::shared_ptr, std::shared_ptr, std::shared_ptr); ~SessionRouterI() override; void destroy(); std::shared_ptr getClientProxy(Ice::optional&, const Ice::Current&) const override; std::shared_ptr getServerProxy(const Ice::Current&) const override; Ice::ObjectProxySeq addProxies(Ice::ObjectProxySeq, const Ice::Current&) override; std::string getCategoryForClient(const Ice::Current&) const override; void createSessionAsync(std::string, std::string, std::function&)>, std::function, const ::Ice::Current&) override; void createSessionFromSecureConnectionAsync( std::function&)>, std::function, const ::Ice::Current&) override; void refreshSessionAsync(std::function, std::function, const ::Ice::Current&) override; void destroySession(const ::Ice::Current&) override; long long int getSessionTimeout(const ::Ice::Current&) const override; int getACMTimeout(const ::Ice::Current&) const override; void updateSessionObservers() override; std::shared_ptr getRouter(const std::shared_ptr&, const Ice::Identity&, bool = true) const; std::shared_ptr getClientBlobject(const std::shared_ptr&, const Ice::Identity&) const; std::shared_ptr getServerBlobject(const std::string&) const; void refreshSession(const std::shared_ptr&); void destroySession(const std::shared_ptr&); int sessionTraceLevel() const { return _sessionTraceLevel; } private: std::shared_ptr getRouterImpl(const std::shared_ptr&, const Ice::Identity&, bool) const; void sessionDestroyException(std::exception_ptr); bool startCreateSession(const std::shared_ptr&, const std::shared_ptr&); void finishCreateSession(const std::shared_ptr&, const std::shared_ptr&); friend class Glacier2::CreateSession; friend class Glacier2::UserPasswordCreateSession; friend class Glacier2::SSLCreateSession; const std::shared_ptr _instance; const int _sessionTraceLevel; const int _rejectTraceLevel; const std::shared_ptr _verifier; const std::shared_ptr _sessionManager; const std::shared_ptr _sslVerifier; const std::shared_ptr _sslSessionManager; std::map, std::shared_ptr> _routersByConnection; mutable std::map, std::shared_ptr>::const_iterator _routersByConnectionHint; std::map> _routersByCategory; mutable std::map>::const_iterator _routersByCategoryHint; std::map, std::shared_ptr> _pending; bool _destroy; mutable std::mutex _mutex; }; } #endif