MCPcopy Create free account
hub / github.com/FastLED/FastLED / acceptClients

Method acceptClients

src/fl/net/http/stream_server.cpp.hpp:65–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65void HttpStreamServer::acceptClients() {
66 if (!isConnected()) {
67 return;
68 }
69
70 // Accept new clients (non-blocking)
71 mNativeServer->acceptClients();
72
73 // Get list of all client IDs
74 fl::vector<u32> clientIds = mNativeServer->getClientIds();
75
76 // Process each client's HTTP header if not already done
77 for (u32 clientId : clientIds) {
78 ClientState* state = getOrCreateClientState(clientId);
79 if (!state) {
80 continue;
81 }
82
83 // If HTTP headers not exchanged yet, do it now
84 if (!state->httpHeaderReceived) {
85 if (readHttpRequestHeader(clientId)) {
86 // Send HTTP response header
87 if (!sendHttpResponseHeader(clientId)) {
88 // Failed to send response, disconnect client
89 disconnectClient(clientId);
90 }
91 }
92 }
93 }
94
95 // Clean up disconnected clients
96 fl::vector<u32> activeClientIds = mNativeServer->getClientIds();
97 fl::vector<u32> toRemove;
98
99 for (auto& pair : mClientStates) {
100 u32 clientId = pair.first;
101 bool found = false;
102 for (u32 activeId : activeClientIds) {
103 if (activeId == clientId) {
104 found = true;
105 break;
106 }
107 }
108 if (!found) {
109 toRemove.push_back(clientId);
110 }
111 }
112
113 for (u32 clientId : toRemove) {
114 removeClientState(clientId);
115 }
116}
117
118size_t HttpStreamServer::getClientCount() const {
119 return mNativeServer ? mNativeServer->getClientCount() : 0;

Callers 5

FL_TEST_FILEFunction · 0.45
FL_TEST_FILEFunction · 0.45
runMethod · 0.45
FL_TEST_FILEFunction · 0.45
serverThreadFuncFunction · 0.45

Calls 2

getClientIdsMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected