NetworkIpHandlerInterface Class Reference

#include <network_webserver.h>

Inheritance diagram for NetworkIpHandlerInterface:

Detailed Description

Interface to access more high level functions to read/send from NetworkConnectionRef. This functions are used by the web server to read and send data.

Public Member Functions

MAXON_METHOD Result< void > InitConnection (const NetworkConnectionRef &connection, const NetworkWebServerRef &webServer)
 
MAXON_METHOD NetworkConnectionRef GetConnection () const
 
MAXON_METHOD NetworkWebServerRef GetWebServer () const
 
MAXON_METHOD Result< void > RecvBytes (const Block< Byte > &data)
 
MAXON_METHOD Result< IntRecvBytesEOS (const Block< Byte > &data)
 
MAXON_METHOD Result< void > ReadLine (String &str)
 
MAXON_METHOD Result< void > SendBytes (const Block< const Byte > &buffer)
 
MAXON_FUNCTION Result< void > SendString (const String &str, const StringEncodingRef &encoding=StringEncodings::Utf8(), Int size=-1)
 
MAXON_FUNCTION Result< void > SendString (const CString &str, Int size=-1)
 
MAXON_METHOD Result< void > FlushWriteBuffer ()
 

Private Member Functions

 MAXON_INTERFACE (NetworkIpHandlerInterface, MAXON_REFERENCE_NORMAL, "net.maxon.interface.networkiphandler")
 

Member Function Documentation

◆ MAXON_INTERFACE()

MAXON_INTERFACE ( NetworkIpHandlerInterface  ,
MAXON_REFERENCE_NORMAL  ,
"net.maxon.interface.networkiphandler"   
)
private

◆ InitConnection()

MAXON_METHOD Result<void> InitConnection ( const NetworkConnectionRef &  connection,
const NetworkWebServerRef &  webServer 
)

Initializes the object with a NetworkConnectionRef. This might be an incoming or outgoing connection.

Parameters
[in]connectionNetworkConnectionRef for low level ip access.
[in]webServerOptional parameter to a NetworkWebServerRef.
Returns
True if the functions was successful.

◆ GetConnection()

MAXON_METHOD NetworkConnectionRef GetConnection ( ) const

Returns the NetworkConnectionRef connected to this object.

◆ GetWebServer()

MAXON_METHOD NetworkWebServerRef GetWebServer ( ) const

Returns the NetworkWebServerRef connected to this object. It may return nullptr if no server is set in this connection.

◆ RecvBytes()

MAXON_METHOD Result<void> RecvBytes ( const Block< Byte > &  data)

Reads the requested number of bytes from the connection. The function will not return before the number of requested bytes has been read or an error occurred.

Parameters
[in]dataBlock for the data to be received.
Returns
OK on success.

◆ RecvBytesEOS()

MAXON_METHOD Result<Int> RecvBytesEOS ( const Block< Byte > &  data)

Reads the requested number of bytes from the connection to the end of the stream. The function will not return before the number of requested bytes has been read, an error occurred or the stream has been closed.

Parameters
[in]dataBlock for the data to be received.
Returns
Returns the number of bytes read or the error.

◆ ReadLine()

MAXON_METHOD Result<void> ReadLine ( String str)

Reads data up to the next return character in the stream.

Parameters
[out]strReference to a string which receives the data.
Returns
True if the functions was successful.

◆ SendBytes()

MAXON_METHOD Result<void> SendBytes ( const Block< const Byte > &  buffer)

Sends data to the connection. Please note that you need to call FlushWriteBuffer() before the data goes out. The functions tries to cache as much as possible before sending each bit separately.

Parameters
[in]bufferBlock with the data to send.
Returns
True if the functions was successful.

◆ SendString() [1/2]

MAXON_FUNCTION Result<void> SendString ( const String str,
const StringEncodingRef &  encoding = StringEncodings::Utf8(),
Int  size = -1 
)

Sends a String. Please note that you need to call FlushWriteBuffer() before the data goes out. The functions tries to cache as much as possible before sending each bit separately.

Parameters
[in]strData string to be send.
[in]encodingString encoding that should be used to convert into 8-bit chars.
[in]size-1 for the complete string. Otherwise the string is sent only with a shortened length.
Returns
True if the functions was successful.

◆ SendString() [2/2]

MAXON_FUNCTION Result<void> SendString ( const CString str,
Int  size = -1 
)

Sends a CString. Please note that you need to call FlushWriteBuffer() before the data goes out. The functions tries to cache as much as possible before sending each bit separately.

Parameters
[in]strData string to be send.
[in]size-1 for the complete string. Otherwise the string is sent only with a shortened length.
Returns
True if the functions was successful.

◆ FlushWriteBuffer()

MAXON_METHOD Result<void> FlushWriteBuffer ( )

Flushes the write cache and forces the data to be send out.

Returns
True if the functions was successful.