Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cXProtocolClient.h
Go to the documentation of this file.
1 //
4 //
5 #ifndef _INC_cXProtocolClient_H
6 #define _INC_cXProtocolClient_H
7 #ifndef NO_PRAGMA_ONCE
8 #pragma once
9 #endif
10 
11 #include "cXProtocol.h"
13 
14 namespace GrayLib
15 {
17  : public cXProtocolBase
18  , public cXProtocolRx
19  , public cXProtocolTx
20  , public IFileCopier
21  {
27 
28  public:
30 
31  protected:
32  // Response to my last action/method invocation.
33  // Server sends client a challenge when connect is started.
34  HRESULT on_Interfaces();
35  HRESULT on_InterfaceDef();
36  HRESULT on_Prop();
37  HRESULT on_Props();
38  HRESULT on_Invoke();
39  HRESULT on_TagDef();
40  HRESULT on_Tags();
41  HRESULT on_Ping();
42  HRESULT onSet_File();
43 
44  // Requested responses.
45  virtual HRESULT onX_Error(HRESULT hResRet, const cVariant& vVal) override;
46  virtual HRESULT onX_Interfaces(UID_t uid, BYTE bInterfaceQty, const SCRIPTINTERFACEID_t* pbInterfaces);
47  virtual HRESULT onX_InterfaceDef(cScriptableInterfaceDynamic* pInterfaceDef);
48  virtual HRESULT onX_Invoke(UID_t uid, SCRIPTINTERFACEID_t bInterfaceID, SCRIPTPROPID_t bPropIndex, const cVariant& vVal);
49  virtual HRESULT onX_TagDef(cScriptTagDef* pTagDef);
50  virtual HRESULT onX_Tag(cXObject* pObj, ATOMCODE_t idTag, const cVariant& vVal);
51  virtual HRESULT onX_Ping(TIMESYS_t dwTime, const char* pszName);
52 
53  virtual HRESULT ProcessStreamRxMsg() override;
54 
55  public:
56  cXProtocolClient(cXProtocolDataMgr* pProtocolDataMgr, cStreamInput* pStreamRx, cStreamOutput* pStreamTx);
57  virtual ~cXProtocolClient();
58 
59  virtual bool isClientSide() const override
60  {
61  return true;
62  }
63  STDMETHOD_(PLEVEL_TYPE, get_PrivLevel)() const override
64  {
66  return PLEVEL_Admin;
67  }
68  STDMETHOD_(cString, get_Name)() const override
69  {
70  return _GT(GRAY_NAMES) _GT("Client");
71  }
72 
73  void InitClient(cStreamInput* pStreamRx, cStreamOutput* pStreamTx);
74 
75  HRESULT Request_Error_Hello();
76 
77  // Request the types of interfaces supported by the object
78  HRESULT Request_Interfaces(UID_t uid);
79  HRESULT Request_Interfaces(cXObject* pObj);
80 
81  // What props and methods does this interface support.
82  HRESULT Request_InterfaceDef(SCRIPTINTERFACEID_t bInterfaceID);
83 
84  // Request all the props in the interface.
85  HRESULT Request_Props(UID_t uid, SCRIPTINTERFACEID_t bInterfaceID = SCRIPTINTERFACEID_MAX);
86  HRESULT Request_Props(cXObject* pObj, SCRIPTINTERFACEID_t bInterfaceID = SCRIPTINTERFACEID_MAX);
87  HRESULT Request_Props(cXObject* pObj, const cScriptableInterfaceDef* pInterface);
88 
89  // Request a specific interfaces property or props.
90  HRESULT Request_Prop(UID_t uid, SCRIPTINTERFACEID_t bInterfaceID, SCRIPTPROPID_t bPropIndex);
91  HRESULT Request_Prop(cXObject* pObj, const cScriptableProp* pProp);
92  HRESULT Set_Prop(UID_t uid, SCRIPTINTERFACEID_t bInterfaceID, SCRIPTPROPID_t bPropIndex, const cVariant& vVal); // Client wants to set a prop on some object.
93  HRESULT Set_Prop(cXObject* pObj, const cScriptableProp* pProp, const cVariant& vVal);
94 
95  // Object Tags
96  HRESULT Request_TagDef(ATOMCODE_t idTag);
97  HRESULT Set_TagDef(UID_t uid, cStringA sName, const cVariant& vVal);
98  HRESULT Request_Tags(UID_t uid);
99  HRESULT Set_Tag(UID_t uid, ATOMCODE_t idTag, const cVariant& vVal);
100 
101  // request to invoke a method on the server
102  HRESULT Request_Invoke(UID_t uid, SCRIPTINTERFACEID_t bInterfaceID, SCRIPTPROPID_t bPropIndex, const cVariant& vValArgs);
103  HRESULT Request_Invoke(cXObject* pObj, const cScriptableMethod* pMethod, const cVariant& vValArgs);
104  HRESULT Request_Invoke(cXObject* pObj, const ATOMCHAR_t* pszMethod, const cVariant& vValArgs);
105 
106  HRESULT Request_Ping(TIMESYSD_t nTimeThrottle = cTimeSys::k_FREQ * 10);
107 
108  // IFileCopier
109  virtual cStringA get_ConnectName() const override;
110  virtual HRESULT RequestFile(const FILECHAR_t* pszSrcName, const FILECHAR_t* pszDesPath, IStreamProgressCallback* pProgress, FILE_SIZE_t nOffsetStart = 0, FILE_SIZE_t* pnRequestSizeEst = nullptr) override;
111  virtual HRESULT SendFile(const FILECHAR_t* pszSrcPath, const FILECHAR_t* pszDestName, IStreamProgressCallback* pProgress, FILE_SIZE_t nOffsetStart = 0, FILE_SIZE_t nSize = (FILE_SIZE_t)-1) override;
112  };
113 };
114 #endif
#define GRAY_NAMES
Use GRAYNAME for string.
Definition: GrayCore.h:34
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
#define _GT(x)
like _T(x) macro for static text.
Definition: StrConst.h:27
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
Definition: cPingClient.h:21
Definition: cScriptableInterfaceDynamic.h:52
Definition: cScriptableInterface.h:300
Definition: cScriptableInterfaceDynamic.h:85
Definition: cScriptableInterface.h:97
Definition: cVariant.h:26
Definition: cXObject.h:78
Definition: cXProtocol.h:84
Definition: cXProtocolClient.h:21
virtual bool isClientSide() const override
Definition: cXProtocolClient.h:59
cPingClientQuery m_PingQuery
Track status of the XPROTO_Ping. Not a real UDP cPingCommon but similar.
Definition: cXProtocolClient.h:29
STDMETHOD_(PLEVEL_TYPE, get_PrivLevel)() const override
Definition: cXProtocolClient.h:63
STDMETHOD_(cString, get_Name)() const override
Definition: cXProtocolClient.h:68
Definition: cXProtocol.h:60
Definition: cXProtocol.h:175
Definition: cXProtocol.h:119
Definition: cStream.h:306
Definition: cStream.h:126
static const TIMESYS_t k_FREQ
milliSec per Sec
Definition: cTimeSys.h:100
Definition: cMesh.h:22
BYTE SCRIPTINTERFACEID_t
enumerate all the defined interface definitions.
Definition: cScriptableInterface.h:35
PLEVEL_TYPE
Definition: PrivLevel.h:16
const SCRIPTINTERFACEID_t SCRIPTINTERFACEID_MAX
Definition: cScriptableInterface.h:36
BYTE SCRIPTPROPID_t
index to method or prop.
Definition: cScriptableEventsMask.h:28
HASHCODE32_t UID_t
Sort of the same as a HASHCODE_t. not the same as UIDINDEX_t.
Definition: cUID.h:18
HASHCODE32_t ATOMCODE_t
Encode a atom as a 32 bit hashcode instead of using its name/pointer. StrT::GetHashCode32()
Definition: cAtom.h:18
INT32 TIMESYSD_t
Time delta. signed milli-Seconds Span. cTimeSys::k_DMAX, cTimeSys::k_INF = MAILSLOT_WAIT_FOREVER.
Definition: cTimeSys.h:28
char FILECHAR_t
a UTF8 char in a file name. like TCHAR
Definition: FileName.h:22
char ATOMCHAR_t
the char form (UNICODE or not) for an atom. (for symbolic names)
Definition: StrConst.h:15
UINT64 FILE_SIZE_t
similar to STREAM_POS_t size_t
Definition: cFileStatus.h:31
UINT32 TIMESYS_t
TIMESYS_t = The normal system tick timer. milli-seconds since start of system/app ?
Definition: cTimeSys.h:27
Definition: cFileCopier.h:17
Definition: cStreamProgress.h:168