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

#include <cXProtocolServer.h>

Inheritance diagram for GrayLib::cXProtocolServerStream:
GrayLib::cProtocolStream GrayLib::cXProtocolBase GrayLib::cXProtocolRx GrayLib::cXProtocolServerTx IAuthUser Gray::cStreamOutput GrayLib::cXProtocolTx Gray::cStreamBase GrayLib::cXProtocolServerStreamImpl

Public Member Functions

 cXProtocolServerStream (cXProtocolFactory *pProtocolFactory, IUnkObject *pServerConnection, cStreamInput *pStreamInp, cStreamOutput *pStreamOut)
 
virtual ~cXProtocolServerStream ()
 
HASHCODE_t get_HashCode () const noexcept
 
virtual bool isClientSide () const override
 
 STDMETHOD_ (cString, get_Name)() const override
 
 STDMETHOD_ (PLEVEL_TYPE, get_PrivLevel)() const override
 
 STDMETHOD_ (bool, CanBeDetectedBy)(const IAuthUser *pViewer) const override
 
virtual HRESULT DisposeThis () override
 
virtual HRESULT ProcessStreamPacket () override
 
virtual HRESULT WriteString (const char *pszStr) override
 
virtual HRESULT OnTickStream () override
 
- Public Member Functions inherited from GrayLib::cProtocolStream
 cProtocolStream (IProtocolFactory *pProtocolFactory, IUnkObject *pServerConnection, cStreamInput *pStreamInp, cStreamOutput *pStreamOut)
 
virtual ~cProtocolStream ()
 
HASHCODE_t get_HashCode () const noexcept
 
 STDMETHOD_ (HASHCODE_t, get_HashCodeX)() const noexcept override
 
 STDMETHOD_ (cString, get_Name)() const override
 
 STDMETHOD_ (cStringA, get_SymName)() const override
 
bool isConnected () const
 
cStreamInputget_StreamInp () const
 
cStreamOutputget_StreamOut () const
 
virtual size_t get_ProtocolMaxMessageSize () const
 
- Public Member Functions inherited from GrayLib::cXProtocolBase
 cXProtocolBase (cXProtocolDataMgr *pProtocolDataMgr)
 
virtual ~cXProtocolBase ()
 
cXProtocolDataMgrget_DataMgr () const
 
- Public Member Functions inherited from GrayLib::cXProtocolServerTx
 cXProtocolServerTx (cXProtocolBase &rBase, cStreamOutput *pOut)
 
virtual ~cXProtocolServerTx ()
 
HRESULT Send_Interfaces (cXObject *pObj)
 
HRESULT Send_InterfaceDef (const cScriptableInterfaceDef *pInterfaceDef)
 
HRESULT Send_InterfaceDef (SCRIPTINTERFACEID_t bInterfaceID)
 
HRESULT Send_InterfaceDefs (cXObject *pObj)
 
HRESULT Send_InterfaceDefs (UID_t uid)
 
HRESULT Send_TagDef (cAtomRef atomref)
 
HRESULT Send_PropsI (cXObject *pObj, const cScriptableInterfaceDef *pInterfaceDef)
 
HRESULT Send_Props (cXObject *pObj, const cScriptableInterfaceDef *pInterfaceDef)
 
HRESULT Send_Props (cXObject *pObj, SCRIPTINTERFACEID_t bInterfaceID)
 
HRESULT Send_Prop (UID_t uid, SCRIPTINTERFACEID_t bInterfaceID, SCRIPTPROPID_t bPropIndex, const cVariant &vVal)
 
HRESULT Send_Prop (cXObject *pObj, const cScriptableProp *pProp, const cVariant &vVal)
 
HRESULT Send_PropGet (cXObject *pObj, const cScriptableProp *pProp)
 
HRESULT Send_InvokeResponse (UID_t uid, SCRIPTINTERFACEID_t bInterfaceID, SCRIPTPROPID_t bMethodIndex, const cVariant &vValRet)
 
HRESULT Send_InvokeResponse (cXObject *pObj, const cScriptableMethod *pMethod, const cVariant &vValRet)
 
HRESULT Send_Tags (cXObject *pObj, bool bSendIfEmpty)
 
HRESULT Send_InvokeResponseV (const cVariant &vValRet)
 
- Public Member Functions inherited from Gray::cStreamOutput
 cStreamOutput () noexcept
 
virtual ~cStreamOutput ()
 
virtual HRESULT WriteX (const void *pData, size_t nDataSize)
 
HRESULT WriteT (const void *pVal, size_t nDataSize)
 
template<typename TYPE >
HRESULT WriteT (TYPE val)
 
HRESULT WriteSize (size_t nSize)
 
HRESULT WriteHashCode (HASHCODE_t nHashCode)
 
HRESULT WriteN (const void *pBuffer, size_t nSize)
 
template<typename _CH >
HRESULT WriteStringN (const _CH *pszStr)
 
template<typename _CH >
HRESULT WriteCharRepeat (_CH nChar, int nCount=1)
 
virtual HRESULT WriteString (const wchar_t *pszStr)
 
StrLen_t VPrintf (const char *pszFormat, va_list args)
 
StrLen_t VPrintf (const wchar_t *pszFormat, va_list args)
 
StrLen_t _cdecl Printf (const char *pszFormat,...)
 
StrLen_t _cdecl Printf (const wchar_t *pszFormat,...)
 
HRESULT WriteStream (cStreamInput &sInp, STREAM_POS_t nSizeMax=k_FILE_BLOCK_SIZE, IStreamProgressCallback *pProgress=nullptr, TIMESYSD_t nTimeout=0)
 Copy cStreamInput to this stream. More...
 
virtual HRESULT FlushX ()
 
- Public Member Functions inherited from Gray::cStreamBase
virtual ~cStreamBase ()
 
virtual STREAM_SEEKRET_t Seek (STREAM_OFFSET_t iOffset, SEEK_ORIGIN_TYPE eSeekOrigin=SEEK_Set)
 
void SeekToBegin ()
 
STREAM_POS_t SeekToEnd ()
 
virtual STREAM_POS_t GetPosition () const
 
virtual STREAM_POS_t GetLength () const
 

Public Attributes

cTimeSys m_timePing
 last time i got a ping from this client More...
 
- Public Attributes inherited from GrayLib::cProtocolStream
IProtocolFactory *const m_pProtocolFactory
 What IProtocolFactory produced this? More...
 
IUnkObject *const m_pServerConnection
 the cNetServerConnection or other top level parent for this protocol. More...
 
HASHCODE_t const m_nHashCode
 the m_pClient->get_HashCode() id for this client connection/stream. 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 onReq_Error ()
 
HRESULT onReq_Interfaces ()
 Request a list of cXObject definitions. More...
 
HRESULT onReq_InterfaceDef ()
 Request the interface definition information from the server. More...
 
HRESULT onReq_Prop ()
 Request prop. More...
 
HRESULT onReq_Props ()
 Request props. More...
 
HRESULT onReq_Invoke ()
 Client Requests a method invocation. More...
 
HRESULT onReq_Tags ()
 
HRESULT onReq_TagDef ()
 
HRESULT onReq_File ()
 
virtual HRESULT onReq_File (const FILECHAR_t *pszReqName, size_t nFilePos)
 
HRESULT onReq_Ping ()
 
virtual HRESULT onX_Error (HRESULT hResRet, const cVariant &vVal) override
 
HRESULT onSet_Prop ()
 Client wants to set a prop on some object. More...
 
HRESULT onSet_Tag ()
 Client wants to set a tag on some object. More...
 
HRESULT onSet_TagDef ()
 
HRESULT onSet_File ()
 
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 ()
 
- 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
 
- Static Public Attributes inherited from Gray::cStreamBase
static const BYTE k_SIZE_MASK = 0x80
 Used for WriteSize() More...
 
static const size_t k_FILE_BLOCK_SIZE = (32 * 1024)
 default arbitrary transfer block size. more than this is NOT more efficient. More...
 
- Protected Attributes inherited from GrayLib::cProtocolStream
cStreamInputm_pStreamInp
 for use with ProcessStreamPacket() More...
 
cStreamOutputm_pStreamOut
 TX responses back to the remote client go here. (e.g. cNetServerConnection->cNetStream) More...
 
cString m_sName
 a user readable name. Usually the IP address or reverse DNS lookup. can be upgraded as lookup or login becomes avail. m_pClient->get_Name() More...
 
- 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

I am the server side of the XProtocol connection. I have the information the client wants. This is a servers representation of a single connection to a client.

Note
Authentication and encryption are outside the scope of this class. Server always gets a XPROTO_Error(S_OK) first as hello. cStreamOutput = for console output for cScriptContext.

Constructor & Destructor Documentation

◆ cXProtocolServerStream()

GrayLib::cXProtocolServerStream::cXProtocolServerStream ( cXProtocolFactory pProtocolFactory,
IUnkObject *  pServerConnection,
cStreamInput pStreamInp,
cStreamOutput pStreamOut 
)

◆ ~cXProtocolServerStream()

GrayLib::cXProtocolServerStream::~cXProtocolServerStream ( )
virtual

Member Function Documentation

◆ DisposeThis()

HRESULT GrayLib::cXProtocolServerStream::DisposeThis ( void  )
overridevirtual

Reimplemented from GrayLib::cProtocolStream.

◆ get_HashCode()

HASHCODE_t GrayLib::cXProtocolServerStream::get_HashCode ( ) const
inlinenoexcept

◆ isClientSide()

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

◆ onReq_Error()

HRESULT GrayLib::cXProtocolServerStream::onReq_Error ( )
protected

XPROTO_Request|XPROTO_Error only get this as the first Request_Error_Hello.

◆ onReq_File() [1/2]

HRESULT GrayLib::cXProtocolServerStream::onReq_File ( )
protected

XPROTO_Request|XPROTO_File Get a request from the client for a file. Send the header to the file.

◆ onReq_File() [2/2]

HRESULT GrayLib::cXProtocolServerStream::onReq_File ( const FILECHAR_t pszReqName,
size_t  nFilePos 
)
protectedvirtual

client is requesting a file. XPROTO_File high level check on the request for the file. Rights to request this file? pszReqName = The name of the file as the client understands it.

Note
OVERRIDE THIS to Translate the name of the file from request to local.

◆ onReq_InterfaceDef()

HRESULT GrayLib::cXProtocolServerStream::onReq_InterfaceDef ( )
protected

Request the interface definition information from the server.

XPROTO_Request|XPROTO_InterfaceDef get the request for an interface definition info from the server.

◆ onReq_Interfaces()

HRESULT GrayLib::cXProtocolServerStream::onReq_Interfaces ( )
protected

Request a list of cXObject definitions.

XPROTO_Request|XPROTO_Interfaces Client is requesting the types of interfaces supported by the object. Ideally this is expressed in _INC_cXProtocol_H ? and known in advance by both parties!

◆ onReq_Invoke()

HRESULT GrayLib::cXProtocolServerStream::onReq_Invoke ( )
protected

Client Requests a method invocation.

XPROTO_Request|XPROTO_Invoke client requests Invoke a method on an object in server. int iMsgNum, cVariant& vVal

◆ onReq_Ping()

HRESULT GrayLib::cXProtocolServerStream::onReq_Ping ( )
protected

XPROTO_Ping Client is requesting a keep alive XPROTO_Ping response from the server. Respond to it now.

◆ onReq_Prop()

HRESULT GrayLib::cXProtocolServerStream::onReq_Prop ( )
protected

Request prop.

XPROTO_Request|XPROTO_Prop Client requests a prop of an object UID_t uid, cVariant& vVal

◆ onReq_Props()

HRESULT GrayLib::cXProtocolServerStream::onReq_Props ( )
protected

Request props.

XPROTO_Request|XPROTO_Props Get props of an objects interface. UID_t uid, cVariant& vVal

◆ onReq_TagDef()

HRESULT GrayLib::cXProtocolServerStream::onReq_TagDef ( )
protected

XPROTO_TagDef get a request for Tag Defs

◆ onReq_Tags()

HRESULT GrayLib::cXProtocolServerStream::onReq_Tags ( )
protected

XPROTO_Tags Got a request for tags

◆ onSet_File()

HRESULT GrayLib::cXProtocolServerStream::onSet_File ( )
protected

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

Note
This can be very large and span multiple TCP packets! use bLastFile
we must be high priv to do this !!!

◆ onSet_Prop()

HRESULT GrayLib::cXProtocolServerStream::onSet_Prop ( )
protected

Client wants to set a prop on some object.

XPROTO_Prop Client wants to set a prop on the server.

◆ onSet_Tag()

HRESULT GrayLib::cXProtocolServerStream::onSet_Tag ( )
protected

Client wants to set a tag on some object.

XPROTO_Tags Client wants to set a tag on some object.

◆ onSet_TagDef()

HRESULT GrayLib::cXProtocolServerStream::onSet_TagDef ( )
protected

XPROTO_TagDef = set/create/clear a tag

◆ OnTickStream()

HRESULT GrayLib::cXProtocolServerStream::OnTickStream ( )
overridevirtual

override for cProtocolStream continue to send blocks of a very large file.

Reimplemented from GrayLib::cProtocolStream.

◆ onX_Error()

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

XPROTO_Error Client sent me back this error. override this virtual

Implements GrayLib::cXProtocolRx.

◆ ProcessStreamPacket()

HRESULT GrayLib::cXProtocolServerStream::ProcessStreamPacket ( )
overridevirtual

cProtocolStream override. incoming data to be processed.

Returns
<0 = error. HRESULT_WIN32_C(ERROR_IO_INCOMPLETE) = not complete message. S_OK = processed full message.

Reimplemented from GrayLib::cProtocolStream.

◆ ProcessStreamRxMsg()

HRESULT GrayLib::cXProtocolServerStream::ProcessStreamRxMsg ( )
overrideprotectedvirtual

cXProtocolRx override. called from cXProtocolRx::ProcessStreamPacket() server(me) is getting a message from the client. m_bMsgReading already set. Read a single message from get_StreamRx() starting after m_bMsgReading

Returns
<0 = error. HRESULT_WIN32_C(ERROR_IO_INCOMPLETE) = not complete message. S_OK = processed full message.

Implements GrayLib::cXProtocolRx.

◆ STDMETHOD_() [1/3]

GrayLib::cXProtocolServerStream::STDMETHOD_ ( bool  ,
CanBeDetectedBy   
) const
inlineoverride

Override IAuthUser

◆ STDMETHOD_() [2/3]

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

Can override IAuthUser for IP + name of the account for the console.

Implements GrayLib::cXProtocolBase.

◆ STDMETHOD_() [3/3]

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

Server side authorization level for the connected client stream.

Note
Override IAuthUser. Authentication, encryption and login are outside the scope of this class.

Implements GrayLib::cXProtocolBase.

◆ WriteString()

HRESULT GrayLib::cXProtocolServerStream::WriteString ( const char *  pszStr)
overridevirtual

cStreamOutput override. Allow this to be used as a console. re-route these to proper format for logging etc. e.g. m_pOutConsole and get_SrcConsole() for cScriptContext

Reimplemented from Gray::cStreamOutput.

Member Data Documentation

◆ m_timePing

cTimeSys GrayLib::cXProtocolServerStream::m_timePing

last time i got a ping from this client


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