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

#include <cProtocol.h>

Inheritance diagram for GrayLib::cProtocolStream:
GrayFTP::cClientFTPBase GrayLib::cHttpProtocolStreamBase GrayLib::cSSLServerStream GrayLib::cSecureServerStream GrayLib::cUnitTestTelnetStream GrayLib::cXProtocolServerStream GrayFTP::cClientFTP GrayFTP::cClientFTPData GrayLib::cHttpProtocolStream GrayLib::cHttpScriptedProtocolStream GrayLib::cXProtocolServerStreamImpl

Public Member Functions

 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
 
virtual HRESULT DisposeThis ()
 
virtual HRESULT OnTickStream ()
 
virtual HRESULT ProcessStreamPacket ()
 

Public Attributes

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...
 

Protected Attributes

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...
 

Detailed Description

Base class for any server side connection to a client talking a protocol. (Used by cNetServer) e.g. base for cHttpProtocolStream, cSecureServerStream, cSSLServerStream, cXProtocolServerStream, cUnitTestTelnetStream might be the base for CClient type class.

Note
This isolates the protocol/client from cNetSocket. Intentionally separate from all CNet* classes. IUnknown so we may use smart pointer but may also be cXObject based.

Constructor & Destructor Documentation

◆ cProtocolStream()

GrayLib::cProtocolStream::cProtocolStream ( IProtocolFactory pProtocolFactory,
IUnkObject *  pServerConnection,
cStreamInput pStreamInp,
cStreamOutput pStreamOut 
)

called by cNetServer after the cProtocolStream is created successfully.

◆ ~cProtocolStream()

GrayLib::cProtocolStream::~cProtocolStream ( )
virtual

Member Function Documentation

◆ DisposeThis()

virtual HRESULT GrayLib::cProtocolStream::DisposeThis ( void  )
inlinevirtual

Kill the connection from my side. or was remotely closed. so clean up gracefully in cNetServer.

Reimplemented in GrayFTP::cClientFTP, GrayLib::cXProtocolServerStream, GrayLib::cSecureServerStream, and GrayFTP::cClientFTPData.

◆ get_HashCode()

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

from m_nHashCode( pClient->get_HashCodeX() )

◆ get_ProtocolMaxMessageSize()

size_t GrayLib::cProtocolStream::get_ProtocolMaxMessageSize ( ) const
virtual

I must be able to hold one full message for processing.

◆ get_StreamInp()

cStreamInput* GrayLib::cProtocolStream::get_StreamInp ( ) const
inline

◆ get_StreamOut()

cStreamOutput* GrayLib::cProtocolStream::get_StreamOut ( ) const
inline

◆ isConnected()

bool GrayLib::cProtocolStream::isConnected ( ) const
inline

◆ OnTickStream()

virtual HRESULT GrayLib::cProtocolStream::OnTickStream ( )
inlinevirtual

Allow the protocol to do stuff on some time tick (not data driven). such as timeout if i don't get any data.

Reimplemented in GrayLib::cXProtocolServerStream, and GrayFTP::cClientFTPData.

◆ ProcessStreamPacket()

virtual HRESULT GrayLib::cProtocolStream::ProcessStreamPacket ( )
inlinevirtual

Incoming m_pStreamInp data handled here. Override this to implement the protocol. Only called if there is new data. I may have to queue up data if incomplete atomic message.

Returns
<0 = error. HRESULT_WIN32_C(ERROR_IO_INCOMPLETE) = not complete message. Caller is responsible to Seek back m_pStreamInp using cStreamTransaction S_OK = processed a single message. commit read.

Reimplemented in GrayLib::cXProtocolServerStream, GrayLib::cSSLServerStream, GrayLib::cSecureServerStream, GrayLib::cHttpProtocolStreamBase, GrayLib::cUnitTestTelnetStream, GrayFTP::cClientFTPData, and GrayFTP::cClientFTP.

◆ STDMETHOD_() [1/3]

GrayLib::cProtocolStream::STDMETHOD_ ( cString  ,
get_Name   
) const
inlineoverride

for IUnkObject user readable name. from m_sName( pClient->get_Name() )

◆ STDMETHOD_() [2/3]

GrayLib::cProtocolStream::STDMETHOD_ ( cStringA  ,
get_SymName   
) const
inlineoverride

Give the stream a unique id.

◆ STDMETHOD_() [3/3]

GrayLib::cProtocolStream::STDMETHOD_ ( HASHCODE_t  ,
get_HashCodeX   
) const
inlineoverridenoexcept

for IUnkObject virtualized version of get_HashCode. from m_nHashCode( pClient->get_HashCodeX() )

Member Data Documentation

◆ m_nHashCode

HASHCODE_t const GrayLib::cProtocolStream::m_nHashCode

the m_pClient->get_HashCode() id for this client connection/stream.

◆ m_pProtocolFactory

IProtocolFactory* const GrayLib::cProtocolStream::m_pProtocolFactory

What IProtocolFactory produced this?

◆ m_pServerConnection

IUnkObject* const GrayLib::cProtocolStream::m_pServerConnection

the cNetServerConnection or other top level parent for this protocol.

◆ m_pStreamInp

cStreamInput* GrayLib::cProtocolStream::m_pStreamInp
protected

for use with ProcessStreamPacket()

◆ m_pStreamOut

cStreamOutput* GrayLib::cProtocolStream::m_pStreamOut
protected

TX responses back to the remote client go here. (e.g. cNetServerConnection->cNetStream)

◆ m_sName

cString GrayLib::cProtocolStream::m_sName
protected

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()


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