Remote Call Framework 3.1
ProxyEndpointService.hpp
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2019, Delta V Software. All rights reserved.
6 // http://www.deltavsoft.com
7 //
8 // RCF is distributed under dual licenses - closed source or GPL.
9 // Consult your particular license for conditions of use.
10 //
11 // If you have not purchased a commercial license, you are using RCF
12 // under GPL terms.
13 //
14 // Version: 3.1
15 // Contact: support <at> deltavsoft.com
16 //
17 //******************************************************************************
18 
19 #ifndef INCLUDE_RCF_PROXYENDPOINTSERVICE_HPP
20 #define INCLUDE_RCF_PROXYENDPOINTSERVICE_HPP
21 
22 #include <RCF/Export.hpp>
23 #include <RCF/RemoteCallContext.hpp>
24 #include <RCF/ServerTransport.hpp>
25 
26 #include <string.h>
27 #include <vector>
28 
29 namespace RCF
30 {
31 
32  class I_ProxyEp;
33 
34  typedef RemoteCallContext<void, std::vector<std::string>&> AmdGetRequests;
35  typedef std::shared_ptr<AmdGetRequests> AmdGetRequestsPtr;
36 
37  class ProxyEndpointEntry
38  {
39  public:
40 
41  ProxyEndpointEntry();
42  ProxyEndpointEntry(const std::string& endpointName);
43 
44  std::string mName;
45  std::vector<std::string> mPendingRequests;
46  RcfSessionWeakPtr mSessionWeakPtr;
47  AmdGetRequestsPtr mAmdPtr;
48  };
49 
50  class ProxyEndpointService : public I_Service
51  {
52  public:
53  virtual void onServiceAdded(RCF::RcfServer &server);
54  virtual void onServiceRemoved(RCF::RcfServer &server);
55  virtual void onServerStart(RCF::RcfServer &server);
56  virtual void onServerStop(RCF::RcfServer &server);
57 
58  private:
59 
60  friend class RcfClient<I_ProxyEp>;
61  friend class RcfServer;
62  friend class RcfSession;
63  friend class ProxyEndpointSession;
64 
65  void enumerateProxyEndpoints(std::vector<std::string>& endpoints);
66  ClientTransportUniquePtr makeProxyEndpointConnection(const std::string& proxyEndpointName);
67  void setupProxiedConnection(RcfSession& session, ClientTransportPtr proxyTransportPtr);
68 
69  void SetupProxyEndpoint(const std::string& endpointName, const std::string& password);
70  //void CloseProxyEndpoint();
71  void GetConnectionRequests(std::vector<std::string>& requests);
72  void MakeConnectionAvailable(const std::string& endpointName, const std::string& requestId);
73 
74  void onConnectionAvailable(
75  const std::string& endpointName,
76  const std::string& requestId,
77  RcfSessionPtr sessionPtr,
78  ClientTransportUniquePtr transportPtr);
79 
80  void removeEndpoint(
81  const std::string& endpointName);
82 
83  RcfServer * mpRcfServer = NULL;
84 
85  Mutex mEntriesMutex;
86  std::map<std::string, ProxyEndpointEntry> mEntries;
87 
88  Mutex mEndpointConnectionsMutex;
89  Condition mEndpointConnectionsCond;
90  std::map<
91  std::pair<std::string, std::string>,
92  ClientTransportUniquePtr> mEndpointConnections;
93 
94 
95  };
96 
97 } // namespace RCF
98 
99 #endif // ! INCLUDE_RCF_PROXYENDPOINTSERVICE_HPP
std::unique_ptr< ClientTransport > ClientTransportUniquePtr
Unique pointer wrapper for RCF::ClientTransport.
Definition: RcfFwd.hpp:43
Provides RCF server-side functionality.
Definition: RcfServer.hpp:54
Definition: AmiIoHandler.hpp:24