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