|
RADLib
RADical C++ application framework
|
Protocol socket wrapper that frames RADTcpSocket byte streams. More...
#include <RADNet.h>
Inheritance diagram for RADNet::RADProtocolSocket:
Collaboration diagram for RADNet::RADProtocolSocket:Public Member Functions | |
| RADProtocolSocket (RADCore::EventLoop &loop) | |
| Creates an unconnected protocol socket. More... | |
| RADProtocolSocket (RADCore::EventLoop &loop, std::shared_ptr< RADTcpSocket > socket) | |
| Wraps an accepted TCP socket. More... | |
| ~RADProtocolSocket () override | |
| Closes the socket. More... | |
| bool | connectToHost (const std::string &host, uint16_t port) |
| Connects to host:port. More... | |
| bool | sendFrame (uint32_t messageId, const std::vector< uint8_t > &payload) |
| Sends a frame. More... | |
| bool | sendFrame (const RADTcpFrame &frame) |
| Sends a frame. More... | |
| void | close () |
| Closes the wrapped socket. More... | |
| bool | isOpen () const |
| Returns true when the wrapped socket is open. More... | |
| void | setMaxPayloadBytes (uint32_t maxPayloadBytes) |
| Sets maximum accepted payload size. More... | |
| void | handleReadyRead () |
| Internal TCP readyRead handler. More... | |
| void | handleError (std::string message) |
| Internal TCP error handler. More... | |
| void | handleConnected () |
| Internal connected handler. More... | |
| void | handleDisconnected () |
| Internal disconnected handler. More... | |
Public Member Functions inherited from RADCore::RADObject | |
| RADObject () | |
| Creates a RADObject bound to the current thread. More... | |
| virtual | ~RADObject () |
| Disconnects tracked event links and releases lifetime token. More... | |
| void | registerLink (const ConnectionRecord &record) |
| Registers a connection for cleanup when this object is destroyed. More... | |
| std::thread::id | threadId () const |
| Returns the thread id this object is currently associated with. More... | |
| EventLoop * | associatedEventLoop () const |
| Returns the associated event loop, if any. More... | |
| ThreadAffinity | threadAffinity () const |
| Returns both thread id and associated loop atomically. More... | |
| std::weak_ptr< void > | lifetimeToken () const |
| Returns a weak token used to drop queued callbacks after destruction. More... | |
| void | moveToThread (std::thread::id tId, EventLoop *loop=nullptr) |
| Moves the object's affinity to tId and optional loop. More... | |
Public Attributes | |
| RADCore::Event< void(RADNet::RADTcpFrame) > | frameReceived |
| Raised when a full frame is received. More... | |
| RADCore::Event< void(std::string) > | errorOccurred |
| Raised on socket or framing errors. More... | |
| RADCore::Event< void() > | connected |
| Raised when connected. More... | |
| RADCore::Event< void() > | disconnected |
| Raised when disconnected. More... | |
Protocol socket wrapper that frames RADTcpSocket byte streams.
|
explicit |
Creates an unconnected protocol socket.
| RADNet::RADProtocolSocket::RADProtocolSocket | ( | RADCore::EventLoop & | loop, |
| std::shared_ptr< RADTcpSocket > | socket | ||
| ) |
Wraps an accepted TCP socket.
|
override |
Closes the socket.
| void RADNet::RADProtocolSocket::close | ( | ) |
Closes the wrapped socket.
| bool RADNet::RADProtocolSocket::connectToHost | ( | const std::string & | host, |
| uint16_t | port | ||
| ) |
Connects to host:port.
| void RADNet::RADProtocolSocket::handleConnected | ( | ) |
Internal connected handler.
| void RADNet::RADProtocolSocket::handleDisconnected | ( | ) |
Internal disconnected handler.
| void RADNet::RADProtocolSocket::handleError | ( | std::string | message | ) |
Internal TCP error handler.
| void RADNet::RADProtocolSocket::handleReadyRead | ( | ) |
Internal TCP readyRead handler.
| bool RADNet::RADProtocolSocket::isOpen | ( | ) | const |
Returns true when the wrapped socket is open.
| bool RADNet::RADProtocolSocket::sendFrame | ( | const RADTcpFrame & | frame | ) |
Sends a frame.
| bool RADNet::RADProtocolSocket::sendFrame | ( | uint32_t | messageId, |
| const std::vector< uint8_t > & | payload | ||
| ) |
Sends a frame.
| void RADNet::RADProtocolSocket::setMaxPayloadBytes | ( | uint32_t | maxPayloadBytes | ) |
Sets maximum accepted payload size.
| RADCore::Event<void () > RADNet::RADProtocolSocket::connected |
Raised when connected.
| RADCore::Event<void () > RADNet::RADProtocolSocket::disconnected |
Raised when disconnected.
| RADCore::Event<void (std::string) > RADNet::RADProtocolSocket::errorOccurred |
Raised on socket or framing errors.
| RADCore::Event<void (RADNet::RADTcpFrame) > RADNet::RADProtocolSocket::frameReceived |
Raised when a full frame is received.