5#ifdef FASTLED_HAS_NETWORKING
19struct ServerClientConnection {
20 asio::ip::tcp::socket socket;
21 HttpConnection connection;
26 : connection(ConnectionConfig())
31 ServerClientConnection(ServerClientConnection&& other)
FL_NOEXCEPT
33 , connection(other.connection)
34 , clientId(other.clientId)
38 ServerClientConnection& operator=(ServerClientConnection&& other)
FL_NOEXCEPT {
41 connection = other.connection;
42 clientId = other.clientId;
48 ServerClientConnection(
const ServerClientConnection&)
FL_NOEXCEPT =
delete;
49 ServerClientConnection& operator=(
const ServerClientConnection&)
FL_NOEXCEPT =
delete;
54class NativeHttpServer {
57 NativeHttpServer(u16 port,
const ConnectionConfig& config = ConnectionConfig());
61 NativeHttpServer(const NativeHttpServer&)
FL_NOEXCEPT = delete;
62 NativeHttpServer& operator=(const NativeHttpServer&)
FL_NOEXCEPT = delete;
67 bool isListening() const;
68 u16 port()
const {
return mPort; }
72 size_t getClientCount()
const;
73 bool hasClient(u32 clientId)
const;
74 void disconnectClient(u32 clientId);
75 void disconnectAllClients();
78 int send(u32 clientId, fl::span<const u8> data);
79 int recv(u32 clientId, fl::span<u8> buffer);
82 void broadcast(fl::span<const u8> data);
85 void update(u32 currentTimeMs);
88 fl::vector<u32> getClientIds()
const;
91 asio::ip::tcp::acceptor& acceptorRef() {
return mAcceptor; }
92 const asio::ip::tcp::acceptor& acceptorRef()
const {
return mAcceptor; }
96 asio::ip::tcp::acceptor mAcceptor;
99 ConnectionConfig mConfig;
100 fl::vector<ServerClientConnection> mClients;
103 bool platformStartListening();
104 void platformStopListening();
107 ServerClientConnection* findClient(u32 clientId);
108 const ServerClientConnection* findClient(u32 clientId)
const;
109 void removeClient(u32 clientId);
110 bool isSocketConnected(
const asio::ip::tcp::socket& sock)
const;
constexpr remove_reference< T >::type && move(T &&t) FL_NOEXCEPT
Base definition for an LED controller.