#include <network_webserver.h>
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< Int > | RecvBytesEOS (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") | |
|
private |
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.
[in] | connection | NetworkConnectionRef for low level ip access. |
[in] | webServer | Optional parameter to a NetworkWebServerRef. |
MAXON_METHOD NetworkConnectionRef GetConnection | ( | ) | const |
Returns the NetworkConnectionRef connected to this object.
MAXON_METHOD NetworkWebServerRef GetWebServer | ( | ) | const |
Returns the NetworkWebServerRef connected to this object. It may return nullptr if no server is set in this connection.
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.
[in] | data | Block for the data to be received. |
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.
[in] | data | Block for the data to be received. |
MAXON_METHOD Result<void> ReadLine | ( | String & | str | ) |
Reads data up to the next return character in the stream.
[out] | str | Reference to a string which receives the data. |
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.
[in] | buffer | Block with the data to send. |
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.
[in] | str | Data string to be send. |
[in] | encoding | String 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. |
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.
[in] | str | Data string to be send. |
[in] | size | -1 for the complete string. Otherwise the string is sent only with a shortened length. |
MAXON_METHOD Result<void> FlushWriteBuffer | ( | ) |
Flushes the write cache and forces the data to be send out.