Closed
Description
Hi. This might be more of a programming question again but...
Something like this works:
void delete_all_faces() {
delete_face_all_in_flash_with_name(&st_face_list);
}
void handle_message(WebsocketsMessage msg) {
if (msg.data() == "delete_all") {
delete_all_faces();
g_state = DELETE_ALL;
}
}
void loop() {
auto client = socket_server.accept();
client.onMessage(handle_message);
while (client.available()) {
client.poll();
switch (g_state) {
case DELETE_ALL:
client.send("All Faces Deleted");
break;
case ...
}
}
}
But I would prefer to send the message from the delete_all_faces function something like this...
void delete_all_faces() {
delete_face_all_in_flash_with_name(&st_face_list);
client.send("All Faces Deleted");
}
void handle_message(WebsocketsMessage msg) {
if (msg.data() == "delete_all") {
delete_all_faces();
}
}
void loop() {
auto client = socket_server.accept();
client.onMessage(handle_message);
while (client.available()) {
...
}
}
Is it possible to make 'client' accessible outside the loop?