Stream client instance handle. (TCP). More...
#include <stream-client.hpp>
Public Member Functions | |
| IStreamClient (const IStreamClient &)=delete | |
| IStreamClient (IStreamClient &&r) noexcept | |
| IStreamClient & | operator= (IStreamClient &)=delete |
| IStreamClient & | operator= (IStreamClient &&r) noexcept |
| IStreamClient ()=default | |
| Creates a new empty stream client instance. (TCP). | |
| IStreamClient (size_t bufferSize=UINT16_MAX+1, double timeoutTime=5.0, SslContextView sslContext=nullptr) | |
| Creates a new stream client instance. (TCP). | |
| void | destroy () noexcept |
| Destroys stream client instance. | |
| virtual void | onConnectionResult (NetsResult result)=0 |
| Stream client connection result function. (TCP). | |
| virtual void | onDisconnect (int reason)=0 |
| Stream client on server disconnect function. (TCP). | |
| virtual int | onStreamReceive (const uint8_t *receiveBuffer, size_t byteCount)=0 |
| Stream client data receive function. (TCP). | |
| virtual int | onDatagramReceive (const uint8_t *receiveBuffer, size_t byteCount)=0 |
| Stream client datagram receive function. (UDP). | |
| virtual string | reasonToString (int reason) |
| Converts reason value to string. | |
| StreamClient_T * | getInstance () const noexcept |
| Returns stream client handle instance. | |
| size_t | getBufferSize () const noexcept |
| Returns stream client receive buffer size. | |
| double | getTimeoutTime () const noexcept |
| Returns stream client server timeout time. (in seconds). | |
| uint8_t * | getBuffer () const noexcept |
| Returns stream client socket locker. | |
| SslContextView | getSslContext () const noexcept |
| Returns stream client socket SSL context instance. | |
| void | setSslContext (SslContextView sslContext=nullptr) noexcept |
| Sets stream client socket SSL context instance. | |
| bool | isSecure () const noexcept |
| Returns true if stream client use encrypted connection. | |
| bool | isRunning () const noexcept |
| Returns true if stream client receive thread is running. | |
| bool | isConnected () const noexcept |
| Returns true if stream client is connected to the server. | |
| void | connect (SocketAddressView remoteAddress, const char *hostname=nullptr) |
| Initiates stream client connection to the server with specified IP address. | |
| void | connect (const char *hostname, const char *service, bool setSNI=true) |
| Initiates stream client connection to the server with specified hostname. | |
| void | disconnect () noexcept |
| Disconnects stream client from the server. | |
| void | update () noexcept |
| Updates stream client state. | |
| void | alive () noexcept |
| Resets stream client server timeout time. | |
| NetsResult | send (const void *data, size_t byteCount) noexcept |
| Sends stream data to the server. (TCP). | |
| NetsResult | send (const OutStreamMessage &message) noexcept |
| Sends stream message to the server. (TCP). | |
| NetsResult | sendDatagram (const void *data, size_t byteCount) noexcept |
| Sends datagram to the server. (UDP). | |
| NetsResult | sendDatagram (const OutStreamMessage &message) noexcept |
| Sends datagram message to the server. (UDP). | |
Protected Attributes | |
| StreamClient_T * | instance = nullptr |
Stream client instance handle. (TCP).
See the stream-client.h
|
inline |
Creates a new stream client instance. (TCP).
See the createStreamClient().
| bufferSize | receive data buffer size in bytes |
| timeoutTime | server timeout time in seconds |
| sslContext | socket SSL context instance or NULL |
| Error | with a NetsResult string on failure. |
|
inlinenoexcept |
Destroys stream client instance.
See the destroyStreamClient().
|
pure virtual |
Stream client connection result function. (TCP).
| result | connection to the server result |
|
pure virtual |
Stream client on server disconnect function. (TCP).
| reason | server disconnection reason |
Stream client data receive function. (TCP).
Client stops receive thread on this function non zero return result.
| [in] | receiveBuffer | received data buffer |
| byteCount | received byte count |
Stream client datagram receive function. (UDP).
Client stops receive thread on this function non zero return result.
| [in] | receiveBuffer | received data buffer |
| byteCount | received byte count |
|
inlinevirtual |
Converts reason value to string.
| reason | target reason value |
|
inlinenoexcept |
Returns stream client receive buffer size.
See the getStreamClientBufferSize().
|
inlinenoexcept |
Returns stream client server timeout time. (in seconds).
See the getStreamClientTimeoutTime().
|
inlinenoexcept |
Returns stream client socket locker.
See the getStreamClientBuffer().
|
inlinenoexcept |
Returns stream client socket SSL context instance.
See the getStreamClientSslContext().
|
inlinenoexcept |
Sets stream client socket SSL context instance.
See the setStreamClientSslContext().
| sslContext | socket SSL context instance or NULL |
|
inlinenoexcept |
Returns true if stream client use encrypted connection.
See the getStreamClientSslContext().
|
inlinenoexcept |
Returns true if stream client receive thread is running.
See the isStreamClientRunning().
|
inlinenoexcept |
Returns true if stream client is connected to the server.
See the isStreamClientConnected().
|
inline |
Initiates stream client connection to the server with specified IP address.
See the connectStreamClientByAddress().
| remoteAddress | remote server IP address | |
| [in] | hostname | remote server hostname or NULL |
| Error | with a NetsResult string on failure. |
|
inline |
Initiates stream client connection to the server with specified hostname.
See the connectStreamClientByHostname().
| [in] | hostname | server hostname string |
| [in] | service | server service string (port) |
| setSNI | set SSL server SNI hostname |
| Error | with a NetsResult string on failure. |
|
inlinenoexcept |
Disconnects stream client from the server.
See the disconnectStreamClient().
|
inlinenoexcept |
Updates stream client state.
See the streamClientUpdate().
| [in] | sendBuffer | data send buffer |
| byteCount | data byte count to send |
|
inlinenoexcept |
Resets stream client server timeout time.
See the aliveStreamClient().
|
inlinenoexcept |
Sends stream data to the server. (TCP).
See the streamClientSend().
| [in] | data | send data buffer |
| byteCount | data byte count to send |
|
inlinenoexcept |
Sends stream message to the server. (TCP).
See the streamClientSend().
| [in] | message | stream message to send |
|
inlinenoexcept |
Sends datagram to the server. (UDP).
See the streamClientSendDatagram().
| [in] | data | send data buffer |
| byteCount | data byte count to send |
|
inlinenoexcept |
Sends datagram message to the server. (UDP).
See the streamClientSendDatagram().
| [in] | message | datagram message to send |