@@ -93,32 +93,13 @@ void HubWebServer::start() {
9393 announceMDNS ();
9494 announceSSDP ();
9595
96- server_->config .max_uri_handlers = 30 ;
96+ server_->config .max_uri_handlers = 40 ;
9797 server_->setPort (80 );
9898 server_->start ();
9999
100100 server_->on (" /" , HTTP_GET , [this ](PsychicRequest *request, PsychicResponse *resp) {
101101
102102 INFO (" webserver() - Rendering / page" );
103- IPAddress remote = request->client ()->remoteIP ();
104-
105- IPAddress apSubnet (192 , 168 , 4 , 0 );
106- IPAddress apSubnetMask (255 , 255 , 255 , 0 );
107- if ((remote & apSubnetMask) == (apSubnet & apSubnetMask))
108- {
109- INFO (" Root request thru AP IP - Redirecting to configuration page" );
110- PsychicStreamResponse response (resp, " text/html" );
111- response.setCode (302 );
112- response.addHeader (" Cache-Control" ," no-cache, must-revalidate" );
113- response.addHeader (" Location" ," /settings.html" );
114- response.setContentLength (0 ),
115-
116- response.beginSend ();
117- return response.endSend ();
118- }
119-
120- unsigned int stackHighWatermark = uxTaskGetStackHighWaterMark (nullptr );
121- INFO (" webserver() - Free HEAP is %d, stackHighWatermark is %d" , ESP .getFreeHeap (), stackHighWatermark);
122103
123104 // Chunked response to optimize RAM usage
124105 size_t content_length = index_html_gz_len;
@@ -444,32 +425,30 @@ void HubWebServer::start() {
444425}
445426
446427void HubWebServer::publishLogMessages () {
447- String logMessage = loggingOutput_->waitForLogMessage (portMAX_DELAY);
448- if (logMessage.length () > 0 ) {
449- if (eventSource_.count () == 0 ) {
450- // No clients connected, skip sending
451- return ;
452- }
428+ String logMessage = loggingOutput_->waitForLogMessage (pdMS_TO_TICKS (5 ));
429+ while (logMessage.length () > 0 ) {
430+ if (eventSource_.count () > 0 ) {
431+ JsonDocument root;
432+ root[" message" ] = logMessage;
453433
454- JsonDocument root ;
455- root[ " message " ] = logMessage ;
434+ String strContent ;
435+ serializeJson ( root, strContent) ;
456436
457- String strContent;
458- serializeJson (root, strContent);
437+ eventSource_. send ( strContent. c_str (), " log " , millis ()) ;
438+ }
459439
460- eventSource_. send (strContent. c_str (), " log " , millis ( ));
440+ logMessage = loggingOutput_-> waitForLogMessage ( pdMS_TO_TICKS ( 5 ));
461441 }
462442}
463443
464444void HubWebServer::publishCommands () {
465- String command = Commands::instance ()->waitForCommand (portMAX_DELAY);
466- if (command.length () > 0 ) {
467- if (eventSource_.count () == 0 ) {
468- // No clients connected, skip sending
469- return ;
445+ String command = Commands::instance ()->waitForCommand (pdMS_TO_TICKS (5 ));
446+ while (command.length () > 0 ) {
447+ if (eventSource_.count () > 0 ) {
448+ eventSource_.send (command.c_str (), " command" , millis ());
470449 }
471450
472- eventSource_. send ( command. c_str (), " command " , millis ( ));
451+ command = Commands::instance ()-> waitForCommand ( pdMS_TO_TICKS ( 5 ));
473452 }
474453}
475454
0 commit comments