Remote Call Framework 3.0
ProxyEndpointService.hpp
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2018, 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.0
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 ProxyEndpointSession;
63 
64  void enumerateProxyEndpoints(std::vector<std::string>& endpoints);
65  ClientTransportUniquePtr makeProxyEndpointConnection(const std::string& proxyEndpointName);
66 
67  void SetupProxyEndpoint(const std::string& endpointName, const std::string& password);
68  //void CloseProxyEndpoint();
69  void GetConnectionRequests(std::vector<std::string>& requests);
70  void MakeConnectionAvailable(const std::string& endpointName, const std::string& requestId);
71 
72  void onConnectionAvailable(
73  const std::string& endpointName,
74  const std::string& requestId,
75  RcfSessionPtr sessionPtr,
76  ClientTransportUniquePtr transportPtr);
77 
78  void removeEndpoint(
79  const std::string& endpointName);
80 
81  RcfServer * mpRcfServer = NULL;
82 
83  Mutex mEntriesMutex;
84  std::map<std::string, ProxyEndpointEntry> mEntries;
85 
86  Mutex mEndpointConnectionsMutex;
87  Condition mEndpointConnectionsCond;
88  std::map<
89  std::pair<std::string, std::string>,
90  ClientTransportUniquePtr> mEndpointConnections;
91 
92 
93  };
94 
95 } // namespace RCF
96 
97 #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