netLink C++ 11
Loading...
Searching...
No Matches
netLink.h
1/*
2 netLink: c++ 11 networking library
3 Copyright (C) 2013-2023 Alexander Meißner
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#pragma once
20
21#include "MsgPackSocket.h"
22
23namespace netLink {
24
27 public:
29 std::function<bool(SocketManager* manager, std::shared_ptr<Socket> serverSocket, std::shared_ptr<Socket> clientSocket)> onConnectRequest;
31 std::function<void(SocketManager* manager, std::shared_ptr<Socket> socket, Socket::Status prev)> onStatusChange;
33 std::function<void(SocketManager* manager, std::shared_ptr<Socket> socket)> onReceiveRaw;
35 std::function<void(SocketManager* manager, std::shared_ptr<Socket> socket, std::unique_ptr<MsgPack::Element> element)> onReceiveMsgPack;
37 std::set<std::shared_ptr<Socket>> sockets;
38
40 std::shared_ptr<Socket> newSocket();
42 std::shared_ptr<Socket> newMsgPackSocket();
43
47 void listen(double waitUpToSeconds = 0.0);
48 };
49
50};