//****************************************************************************** // RCF - Remote Call Framework // Copyright (c) 2005 - 2007. All rights reserved. // Consult your license for conditions of use. // Developed by Jarl Lindrud. // Contact: jlindrud@hotmail.com . //****************************************************************************** #ifndef INCLUDE_RCF_ENDPOINTSERVERSERVICE_HPP #define INCLUDE_RCF_ENDPOINTSERVERSERVICE_HPP #include #include #include #include #include #include #include #include namespace RCF { class RcfServer; class I_Endpoint; class I_ServerTransport; class I_ClientTransport; //template //class RcfClient; //class I_EndpointBroker; //template<> class RcfClient; typedef std::auto_ptr ClientTransportAutoPtr; class EndpointServer { public: typedef int EndpointId; EndpointServer() : mEndpointId(RCF_DEFAULT_INIT) {} EndpointId getEndpointId() { return mEndpointId; } // remotely invoked (on the master connection) bool spawnConnections(unsigned int requestedConnections); private: friend class EndpointServerService; std::string mEndpointName; std::string mEndpointClientPassword; std::string mEndpointServerPassword; EndpointId mEndpointId; typedef RcfClient Client; typedef boost::shared_ptr< Client > ClientPtr; std::list mClients; }; typedef boost::shared_ptr EndpointServerPtr; typedef boost::weak_ptr EndpointServerWeakPtr; class EndpointServerService : public I_Service, boost::noncopyable { public: typedef EndpointServer::EndpointId EndpointId; EndpointServerService(); void onServiceAdded(RcfServer &server); void onServiceRemoved(RcfServer &server); void onServerClose(RcfServer &server); EndpointId openEndpoint( const I_Endpoint &brokerEndpoint, const std::string &endpointName); EndpointId openEndpoint( ClientTransportAutoPtr clientTransportAutoPtr, const std::string &endpointName); void closeEndpoint(EndpointId endpointId); private: EndpointId getNextEndpointId(); ServerTransportPtr mServerTransportPtr; ReadWriteMutex mEndpointServersMutex; std::map mEndpointServers; }; typedef boost::shared_ptr EndpointServerServicePtr; } // namespace RCF #endif // ! INCLUDE_RCF_ENDPOINTSERVERSERVICE_HPP