Переглянути джерело

Make REST state updates non-blocking by default. Add query parameter blockOnQueue to allow them to be blocking if desired.

Christopher Mullins 6 роки тому
батько
коміт
713a0bf78d
1 змінених файлів з 3 додано та 1 видалено
  1. 3 1
      lib/WebServer/MiLightHttpServer.cpp

+ 3 - 1
lib/WebServer/MiLightHttpServer.cpp

@@ -322,9 +322,11 @@ void MiLightHttpServer::handleListenGateway(RequestContext& request) {
 }
 
 void MiLightHttpServer::sendGroupState(BulbId& bulbId, GroupState* state, RichHttp::Response& response) {
+  bool blockOnQueue = server.arg("blockOnQueue").equalsIgnoreCase("true");
+
   // Wait for packet queue to flush out.  State will not have been updated before that.
   // Bit hacky to call loop outside of main loop, but should be fine.
-  while (packetSender->isSending()) {
+  while (blockOnQueue && packetSender->isSending()) {
     packetSender->loop();
   }