SNode.C
Loading...
Searching...
No Matches
SocketContext.h
Go to the documentation of this file.
1/*
2 * SNode.C - a slim toolkit for network communication
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2020, 2021, 2022, 2023, 2024, 2025
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef IOT_MQTT_SOCKETCONTEXT_H
21#define IOT_MQTT_SOCKETCONTEXT_H
22
23#include "core/socket/stream/SocketContext.h"
24#include "iot/mqtt/MqttContext.h"
25
26namespace core::socket::stream {
27 class SocketConnection;
28}
29
30namespace iot::mqtt {
31 class Mqtt;
32}
33
34#ifndef DOXYGEN_SHOULD_SKIP_THIS
35
36#include <cstddef>
37
38#endif // DOXYGEN_SHOULD_SKIP_THIS
39
40namespace iot::mqtt {
41
43 : public core::socket::stream::SocketContext
44 , private iot::mqtt::MqttContext {
45 public:
46 explicit SocketContext(core::socket::stream::SocketConnection* socketConnection, Mqtt* mqtt);
47
48 private:
49 void onConnected() override;
50 std::size_t onReceivedFromPeer() override;
51 void onDisconnected() override;
52 bool onSignal(int sig) override;
53
54 core::socket::stream::SocketConnection* getSocketConnection() const override;
55
56 std::size_t recv(char* chunk, std::size_t chunklen) override;
57 void send(const char* chunk, std::size_t chunklen) override;
58
59 void end(bool fatal) override;
60 void close() override;
61 };
62
63} // namespace iot::mqtt
64
65#endif // IOT_MQTT_SOCKETCONTEXT_H
SocketConnection * getSocketConnection() const
SocketContext(core::socket::stream::SocketConnection *socketConnection)
std::size_t readFromPeer(char *chunk, std::size_t chunklen) const final
void sendToPeer(const char *chunk, std::size_t chunkLen) const final
void shutdownWrite(bool forceClose=false)
std::size_t onReceivedFromPeer()
bool onSignal(int sig) override
void send(const char *chunk, std::size_t chunklen) override
SocketContext(core::socket::stream::SocketConnection *socketConnection, Mqtt *mqtt)
void onDisconnected() override
void end(bool fatal) override
std::size_t recv(char *chunk, std::size_t chunklen) override
void onConnected() override
core::socket::stream::SocketConnection * getSocketConnection() const override
std::size_t onReceivedFromPeer() override