Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cXProtocolClient Class Reference

#include <cXProtocolClient.h>

Inheritance diagram for GrayLib::cXProtocolClient:
GrayLib::cXProtocolBase GrayLib::cXProtocolRx GrayLib::cXProtocolTx Gray::IFileCopier

Public Member Functions

 cXProtocolClient (cXProtocolDataMgr *pProtocolDataMgr, cStreamInput *pStreamRx, cStreamOutput *pStreamTx)
 
virtual ~cXProtocolClient ()
 
virtual bool isClientSide () const override
 
 STDMETHOD_ (PLEVEL_TYPE, get_PrivLevel)() const override
 
 STDMETHOD_ (cString, get_Name)() const override
 
void InitClient (cStreamInput *pStreamRx, cStreamOutput *pStreamTx)
 
HRESULT Request_Error_Hello ()
 
HRESULT Request_Interfaces (UID_t uid)
 
HRESULT Request_Interfaces (cXObject *pObj)
 
HRESULT Request_InterfaceDef (SCRIPTINTERFACEID_t bInterfaceID)
 
HRESULT Request_Props (UID_t uid, SCRIPTINTERFACEID_t bInterfaceID=SCRIPTINTERFACEID_MAX)
 
HRESULT Request_Props (cXObject *pObj, SCRIPTINTERFACEID_t bInterfaceID=SCRIPTINTERFACEID_MAX)
 
HRESULT Request_Props (cXObject *pObj, const cScriptableInterfaceDef *pInterface)
 
HRESULT Request_Prop (UID_t uid, SCRIPTINTERFACEID_t bInterfaceID, SCRIPTPROPID_t bPropIndex)
 
HRESULT Request_Prop (cXObject *pObj, const cScriptableProp *pProp)
 
HRESULT Set_Prop (UID_t uid, SCRIPTINTERFACEID_t bInterfaceID, SCRIPTPROPID_t bPropIndex, const cVariant &vVal)
 
HRESULT Set_Prop (cXObject *pObj, const cScriptableProp *pProp, const cVariant &vVal)
 
HRESULT Request_TagDef (ATOMCODE_t idTag)
 
HRESULT Set_TagDef (UID_t uid, cStringA sName, const cVariant &vVal)
 
HRESULT Request_Tags (UID_t uid)
 
HRESULT Set_Tag (UID_t uid, ATOMCODE_t idTag, const cVariant &vVal)
 
HRESULT Request_Invoke (UID_t uid, SCRIPTINTERFACEID_t bInterfaceID, SCRIPTPROPID_t bPropIndex, const cVariant &vValArgs)
 
HRESULT Request_Invoke (cXObject *pObj, const cScriptableMethod *pMethod, const cVariant &vValArgs)
 
HRESULT Request_Invoke (cXObject *pObj, const ATOMCHAR_t *pszMethod, const cVariant &vValArgs)
 
HRESULT Request_Ping (TIMESYSD_t nTimeThrottle=cTimeSys::k_FREQ *10)
 
virtual cStringA get_ConnectName () const override
 get a debug name for the connection. More...
 
virtual HRESULT RequestFile (const FILECHAR_t *pszSrcName, const FILECHAR_t *pszDesPath, IStreamProgressCallback *pProgress, FILE_SIZE_t nOffsetStart=0, FILE_SIZE_t *pnRequestSizeEst=nullptr) override
 
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
 
- Public Member Functions inherited from GrayLib::cXProtocolBase
 cXProtocolBase (cXProtocolDataMgr *pProtocolDataMgr)
 
virtual ~cXProtocolBase ()
 
cXProtocolDataMgrget_DataMgr () const
 
- Public Member Functions inherited from Gray::IFileCopier
virtual ~ IFileCopier ()
 
virtual HRESULT Connect (const FILECHAR_t *pszDevice)
 
virtual HRESULT SendAttr (const FILECHAR_t *pszDestName, cTimeFile timeChanged)
 

Public Attributes

cPingClientQuery m_PingQuery
 Track status of the XPROTO_Ping. Not a real UDP cPingCommon but similar. More...
 
- Public Attributes inherited from GrayLib::cXProtocolBase
cXProtocolDataMgr *const m_pProtocolDataMgr
 Point back to the protocol singleton. More...
 
bool m_bUseHashPropName
 for stuff i send, should i hash the prop names ? XPROTO_HashProp More...
 
cFile m_FileWork
 The local file we are reading or writing for XPROTO_File. More...
 

Protected Member Functions

HRESULT on_Interfaces ()
 Get a list of cXObject definitions. More...
 
HRESULT on_InterfaceDef ()
 Get the interface definition info from the server. More...
 
HRESULT on_Prop ()
 Get prop data. response from my request for a prop. More...
 
HRESULT on_Props ()
 Get props. response from my request for a props. More...
 
HRESULT on_Invoke ()
 The response from the method invocation. More...
 
HRESULT on_TagDef ()
 
HRESULT on_Tags ()
 
HRESULT on_Ping ()
 
HRESULT onSet_File ()
 
virtual HRESULT onX_Error (HRESULT hResRet, const cVariant &vVal) override
 
virtual HRESULT onX_Interfaces (UID_t uid, BYTE bInterfaceQty, const SCRIPTINTERFACEID_t *pbInterfaces)
 
virtual HRESULT onX_InterfaceDef (cScriptableInterfaceDynamic *pInterfaceDef)
 
virtual HRESULT onX_Invoke (UID_t uid, SCRIPTINTERFACEID_t bInterfaceID, SCRIPTPROPID_t bPropIndex, const cVariant &vVal)
 
virtual HRESULT onX_TagDef (cScriptTagDef *pTagDef)
 
virtual HRESULT onX_Tag (cXObject *pObj, ATOMCODE_t idTag, const cVariant &vVal)
 
virtual HRESULT onX_Ping (TIMESYS_t dwTime, const char *pszName)
 
virtual HRESULT ProcessStreamRxMsg () override
 
- Protected Member Functions inherited from GrayLib::cXProtocolRx
 cXProtocolRx (cXProtocolBase &rBase, cStreamInput *pStreamRx)
 
virtual ~cXProtocolRx ()
 
virtual HRESULT onXSet_Prop (cXObject *pObj, const cScriptableProp *pProp, const cVariant &vVal)
 
virtual HRESULT onXReq_Invoke (cXObject *pObj, const cScriptableMethod *pMethod, const cVariant &vArgs, OUT cVariant &vValRet)
 
virtual HRESULT onXSet_PropN (UID_t uidLastRx, const ATOMCHAR_t *pszPropName, ATOMCODE_t nPropName, const cVariant &vVal)
 
virtual HRESULT onXReq_InvokeN (UID_t uidLastRx, const ATOMCHAR_t *pszMethodName, ATOMCODE_t nMethodName, const cVariant &vArgs)
 
virtual HRESULT onXSet_File (const FILECHAR_t *pszReqName, size_t dwTotalLen)
 
void InitRx ()
 
HRESULT ReadUID ()
 
HRESULT on_Error ()
 
HRESULT onSet_PropN ()
 
HRESULT onReq_InvokeN ()
 
HRESULT onSet_File ()
 
HRESULT onSet_FileNext ()
 
cStreamInputget_StreamRx ()
 
virtual HRESULT ProcessStreamPacket ()
 
- Protected Member Functions inherited from GrayLib::cXProtocolTx
void InitTx ()
 
HRESULT Send_MsgPropName (const ATOMCHAR_t *pszPropName)
 
cStreamOutputget_StreamTx () const
 
 cXProtocolTx (cXProtocolBase &rBase, cStreamOutput *pStreamTx)
 
virtual ~cXProtocolTx ()
 
bool IsTxMsgBuilding () const
 
HRESULT Send_MsgHeader (XPROTO_t bMsg)
 
HRESULT Send_MsgHeaderUID (XPROTO_t bMsg, UID_t uid)
 
void Send_MsgEnd ()
 
HRESULT Send_Error (HRESULT hResRet, const cVariant &vVal)
 
HRESULT Send_PropN (UID_t uid, const ATOMCHAR_t *pszPropName, const cVariant &vVal)
 
HRESULT Send_PropN (cXObject *pObj, const ATOMCHAR_t *pszPropName, const cVariant &vValRet)
 
HRESULT Send_PropN (cXObject *pObj, const cScriptableProp *pProp, const cVariant &vValRet)
 
HRESULT Request_InvokeN (UID_t uid, const ATOMCHAR_t *pszPropName, const cVariant &vArgs)
 
HRESULT Request_InvokeN (UID_t uid, const ATOMCHAR_t *pszPropName)
 
HRESULT Request_InvokeN (cXObject *pObj, const ATOMCHAR_t *pszPropName, const cVariant &vArgs)
 
HRESULT Request_InvokeN (cXObject *pObj, const ATOMCHAR_t *pszPropName)
 
HRESULT Request_InvokeN (cXObject *pObj, const cScriptableMethod *pMethod, const cVariant &vArgs)
 
HRESULT Send_FileChecked (const FILECHAR_t *pszSrcPath, const FILECHAR_t *pszDestName)
 
HRESULT Send_File (const FILECHAR_t *pszSrcPath, const FILECHAR_t *pszDestName, FILE_SIZE_t nOffsetStart, FILE_SIZE_t nSize)
 
HRESULT Send_FileNext ()
 

Additional Inherited Members

- Static Public Member Functions inherited from GrayLib::cXProtocolBase
static cStringA GRAYCALL GetMsgName (XPROTO_t bMsg)
 
- Static Public Attributes inherited from GrayLib::cXProtocolBase
static const size_t k_Packet_Size_Max = cStream::k_FILE_BLOCK_SIZE + 16
 
- Protected Attributes inherited from GrayLib::cXProtocolRx
cXProtocolBasem_rBase
 Input stream. More...
 
cStreamInputm_pStreamRx
 Where to RX from. More...
 
SCRIPTINTERFACEID_t m_bInterfaceIDUnk
 An interface received that I don't understand (yet)! client only. More...
 
XPROTO_t m_bMsgReading
 We are in the process of reading/dispatching a message. More...
 
XPROTO_t m_bMsgReadPrev
 Last message i got and understood. for debug. More...
 
int m_iMsgNumRx
 Count the messages we received. More...
 
UID_t m_uidLastRx
 Last UID sent from client. ( be careful order of messages does not change!) More...
 
- Protected Attributes inherited from GrayLib::cXProtocolTx
cXProtocolBasem_rBase
 My parent. dumb pointer. More...
 
cStreamOutputm_pStreamTx
 Where to TX to. More...
 
XPROTO_t m_bMsgBuilding
 We are in the process of building a message. not called Send_MsgEnd() yet. More...
 
bool m_bFileSending
 Must call Send_FileNext() until done. More...
 
int m_iMsgNumTx
 Count the messages we transmit. More...
 
UID_t m_uidLastTx
 Last UID i sent. Periodically resend this just in case the other side gets out of sync ? More...
 

Detailed Description

This is the client. I want access to a servers objects. This is a client side connection to a server.

Note
Object UID=0 is always the gateway object. XObjType=0,index=0
Authentication and encryption are outside the scope of this class.

Constructor & Destructor Documentation

◆ cXProtocolClient()

GrayLib::cXProtocolClient::cXProtocolClient ( cXProtocolDataMgr pProtocolDataMgr,
cStreamInput pStreamRx,
cStreamOutput pStreamTx 
)

◆ ~cXProtocolClient()

GrayLib::cXProtocolClient::~cXProtocolClient ( )
virtual

Member Function Documentation

◆ get_ConnectName()

cStringA GrayLib::cXProtocolClient::get_ConnectName ( ) const
overridevirtual

get a debug name for the connection.

IFileCopier get_ProtocolName()

Implements Gray::IFileCopier.

◆ InitClient()

void GrayLib::cXProtocolClient::InitClient ( cStreamInput pStreamRx,
cStreamOutput pStreamTx 
)

◆ isClientSide()

virtual bool GrayLib::cXProtocolClient::isClientSide ( ) const
inlineoverridevirtual

◆ on_InterfaceDef()

HRESULT GrayLib::cXProtocolClient::on_InterfaceDef ( )
protected

Get the interface definition info from the server.

XPROTO_InterfaceDef Get the interface definition info from the server. list or props and methods.

◆ on_Interfaces()

HRESULT GrayLib::cXProtocolClient::on_Interfaces ( )
protected

Get a list of cXObject definitions.

XPROTO_Interfaces Get a list of cXObject definitions.

◆ on_Invoke()

HRESULT GrayLib::cXProtocolClient::on_Invoke ( )
protected

The response from the method invocation.

XPROTO_Invoke The response from my previous server side method invocation.

◆ on_Ping()

HRESULT GrayLib::cXProtocolClient::on_Ping ( )
protected

XPROTO_Ping Get my XPROTO_Ping response from the server.

◆ on_Prop()

HRESULT GrayLib::cXProtocolClient::on_Prop ( )
protected

Get prop data. response from my request for a prop.

XPROTO_Prop Get prop of an object from server. I probably requested this.

◆ on_Props()

HRESULT GrayLib::cXProtocolClient::on_Props ( )
protected

Get props. response from my request for a props.

XPROTO_Props Get all the props on an interface for the object. (from the server) Most likely i requested this! Send_PropsI() sent

◆ on_TagDef()

HRESULT GrayLib::cXProtocolClient::on_TagDef ( )
protected

XPROTO_TagDef

◆ on_Tags()

HRESULT GrayLib::cXProtocolClient::on_Tags ( )
protected

XPROTO_Tags - get response back for request for tags on server object. from cXProtocolServerTx::Send_Tags()

◆ onSet_File()

HRESULT GrayLib::cXProtocolClient::onSet_File ( )
protected

XPROTO_File i am setting a file to the client from the server

Note
This can be very large and span multiple TCP packets! use bLastFile

◆ onX_Error()

HRESULT GrayLib::cXProtocolClient::onX_Error ( HRESULT  hResRet,
const cVariant vVal 
)
overrideprotectedvirtual

XPROTO_Error Server sent me back this error. override this virtual

Implements GrayLib::cXProtocolRx.

◆ onX_InterfaceDef()

HRESULT GrayLib::cXProtocolClient::onX_InterfaceDef ( cScriptableInterfaceDynamic pInterfaceDef)
protectedvirtual

XPROTO_InterfaceDef We just got this interface definition from the server. override this virtual

◆ onX_Interfaces()

HRESULT GrayLib::cXProtocolClient::onX_Interfaces ( UID_t  uid,
BYTE  bInterfaceQty,
const SCRIPTINTERFACEID_t pbInterfaces 
)
protectedvirtual

XPROTO_Interfaces list all the interfaces used by this object. override this virtual

◆ onX_Invoke()

HRESULT GrayLib::cXProtocolClient::onX_Invoke ( UID_t  uid,
SCRIPTINTERFACEID_t  bInterfaceID,
SCRIPTPROPID_t  bPropIndex,
const cVariant vVal 
)
protectedvirtual

XPROTO_Invoke I previously fired a method on the server. This is the response. consume the Method response i got from the server. No real default behavior here. override this virtual. SCRIPTPROPID_t

◆ onX_Ping()

HRESULT GrayLib::cXProtocolClient::onX_Ping ( TIMESYS_t  dwTime,
const char *  pszName 
)
protectedvirtual

XPROTO_Ping

◆ onX_Tag()

HRESULT GrayLib::cXProtocolClient::onX_Tag ( cXObject pObj,
ATOMCODE_t  idTag,
const cVariant vVal 
)
protectedvirtual

XPROTO_Tags override this virtual

◆ onX_TagDef()

HRESULT GrayLib::cXProtocolClient::onX_TagDef ( cScriptTagDef pTagDef)
protectedvirtual

XPROTO_TagDef override this virtual

◆ ProcessStreamRxMsg()

HRESULT GrayLib::cXProtocolClient::ProcessStreamRxMsg ( )
overrideprotectedvirtual

cXProtocolRx override Client (me) is getting a message from the server. m_bMsgReading already set. read a single message from get_StreamRx() starting after m_bMsgReading Mostly data i requested.

Returns
HRESULT_WIN32_C(ERROR_IO_INCOMPLETE) = not a real error. wait for more data.
Note
Most errors returned from here mean we should drop the connection?!

Implements GrayLib::cXProtocolRx.

◆ Request_Error_Hello()

HRESULT GrayLib::cXProtocolClient::Request_Error_Hello ( )

Send a XPROTO_Error request to the server as my hello message.

◆ Request_InterfaceDef()

HRESULT GrayLib::cXProtocolClient::Request_InterfaceDef ( SCRIPTINTERFACEID_t  bInterfaceID)

XPROTO_InterfaceDef What props and methods does this interface support.

◆ Request_Interfaces() [1/2]

HRESULT GrayLib::cXProtocolClient::Request_Interfaces ( cXObject pObj)

XPROTO_Interfaces Request the types of interfaces supported by the object

◆ Request_Interfaces() [2/2]

HRESULT GrayLib::cXProtocolClient::Request_Interfaces ( UID_t  uid)

XPROTO_Interfaces Request a list of the interfaces supported by the object

◆ Request_Invoke() [1/3]

HRESULT GrayLib::cXProtocolClient::Request_Invoke ( cXObject pObj,
const ATOMCHAR_t pszMethod,
const cVariant vValArgs 
)

XPROTO_Invoke Request to invoke a method on a server side object.

◆ Request_Invoke() [2/3]

HRESULT GrayLib::cXProtocolClient::Request_Invoke ( cXObject pObj,
const cScriptableMethod pMethod,
const cVariant vValArgs 
)

XPROTO_Invoke Request to invoke a method on a server side object.

◆ Request_Invoke() [3/3]

HRESULT GrayLib::cXProtocolClient::Request_Invoke ( UID_t  uid,
SCRIPTINTERFACEID_t  bInterfaceID,
SCRIPTPROPID_t  bPropIndex,
const cVariant vValArgs 
)

XPROTO_Invoke request to invoke a method on the server. will call onReq_Invoke() on the server side.

◆ Request_Ping()

HRESULT GrayLib::cXProtocolClient::Request_Ping ( TIMESYSD_t  nTimeThrottle = cTimeSys::k_FREQ * 10)

Send a XPROTO_Ping request to the server

  • nTimeThrottle = Throttle sending pings to my server.

◆ Request_Prop() [1/2]

HRESULT GrayLib::cXProtocolClient::Request_Prop ( cXObject pObj,
const cScriptableProp pProp 
)

XPROTO_Prop

◆ Request_Prop() [2/2]

HRESULT GrayLib::cXProtocolClient::Request_Prop ( UID_t  uid,
SCRIPTINTERFACEID_t  bInterfaceID,
SCRIPTPROPID_t  bPropIndex 
)

XPROTO_Prop Request a specific interfaces property or props. uid= pObj->get_UIDValue()

◆ Request_Props() [1/3]

HRESULT GrayLib::cXProtocolClient::Request_Props ( cXObject pObj,
const cScriptableInterfaceDef pInterface 
)

◆ Request_Props() [2/3]

HRESULT GrayLib::cXProtocolClient::Request_Props ( cXObject pObj,
SCRIPTINTERFACEID_t  bInterfaceID = SCRIPTINTERFACEID_MAX 
)

◆ Request_Props() [3/3]

HRESULT GrayLib::cXProtocolClient::Request_Props ( UID_t  uid,
SCRIPTINTERFACEID_t  bInterfaceID = SCRIPTINTERFACEID_MAX 
)

XPROTO_Props Request all the props for an interface on an object.

  • uid = cUID::k_ROOT bInterfaceID = SCRIPTINTERFACEID_MAX = all interfaces for the object.

◆ Request_TagDef()

HRESULT GrayLib::cXProtocolClient::Request_TagDef ( ATOMCODE_t  idTag)

XPROTO_TagDef Request a tag def for a idTag which is the same as atom id on server!

◆ Request_Tags()

HRESULT GrayLib::cXProtocolClient::Request_Tags ( UID_t  uid)

XPROTO_Tags

◆ RequestFile()

HRESULT GrayLib::cXProtocolClient::RequestFile ( const FILECHAR_t pszSrcName,
const FILECHAR_t pszDesPath,
IStreamProgressCallback pProgress,
FILE_SIZE_t  nOffsetStart = 0,
FILE_SIZE_t pnRequestSizeEst = nullptr 
)
overridevirtual

IFileCopier XPROTO_Request|XPROTO_File I (Client) is requesting a file from the server.

  • pszFileReq = what is the name of the file i am requesting from the server (may be relative path). pszPathDest = the full local path to store the file. uFlags = what about the file do we want ? just size and CRC32 of file ?

Reimplemented from Gray::IFileCopier.

◆ SendFile()

HRESULT GrayLib::cXProtocolClient::SendFile ( const FILECHAR_t pszSrcPath,
const FILECHAR_t pszDestName,
IStreamProgressCallback pProgress,
FILE_SIZE_t  nOffsetStart = 0,
FILE_SIZE_t  nSize = (FILE_SIZE_t)-1 
)
overridevirtual

Send a file to the server. IFileCopier

  • pszSrcPath = local side source name. pszDestName = server side destination name. (suggested)

Reimplemented from Gray::IFileCopier.

◆ Set_Prop() [1/2]

HRESULT GrayLib::cXProtocolClient::Set_Prop ( cXObject pObj,
const cScriptableProp pProp,
const cVariant vVal 
)

XPROTO_Prop

◆ Set_Prop() [2/2]

HRESULT GrayLib::cXProtocolClient::Set_Prop ( UID_t  uid,
SCRIPTINTERFACEID_t  bInterfaceID,
SCRIPTPROPID_t  bPropIndex,
const cVariant vVal 
)

XPROTO_Prop Client wants to set a prop on some object in the server.

◆ Set_Tag()

HRESULT GrayLib::cXProtocolClient::Set_Tag ( UID_t  uid,
ATOMCODE_t  idTag,
const cVariant vVal 
)

XPROTO_Tags Set an existing tag on the server side data object.

◆ Set_TagDef()

HRESULT GrayLib::cXProtocolClient::Set_TagDef ( UID_t  uid,
cStringA  sName,
const cVariant vVal 
)

XPROTO_TagDef Set/Create New tag from the client to the server.

◆ STDMETHOD_() [1/2]

GrayLib::cXProtocolClient::STDMETHOD_ ( cString  ,
get_Name   
) const
inlineoverridevirtual

◆ STDMETHOD_() [2/2]

GrayLib::cXProtocolClient::STDMETHOD_ ( PLEVEL_TYPE  ,
get_PrivLevel   
) const
inlineoverridevirtual

Clients always consider server to be highest priv.

Implements GrayLib::cXProtocolBase.

Member Data Documentation

◆ m_PingQuery

cPingClientQuery GrayLib::cXProtocolClient::m_PingQuery

Track status of the XPROTO_Ping. Not a real UDP cPingCommon but similar.


The documentation for this class was generated from the following files: