mirror of
https://github.com/me-no-dev/ESPAsyncWebServer.git
synced 2025-09-27 14:50:56 +02:00
@@ -23,6 +23,8 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "AsyncEventSource.h"
|
#include "AsyncEventSource.h"
|
||||||
|
|
||||||
|
#define ASYNC_SSE_NEW_LINE_CHAR (char)0xa
|
||||||
|
|
||||||
using namespace asyncsrv;
|
using namespace asyncsrv;
|
||||||
|
|
||||||
static String generateEventMessage(const char* message, const char* event, uint32_t id, uint32_t reconnect) {
|
static String generateEventMessage(const char* message, const char* event, uint32_t id, uint32_t reconnect) {
|
||||||
@@ -41,19 +43,19 @@ static String generateEventMessage(const char* message, const char* event, uint3
|
|||||||
if (reconnect) {
|
if (reconnect) {
|
||||||
str += T_retry_;
|
str += T_retry_;
|
||||||
str += reconnect;
|
str += reconnect;
|
||||||
str += (char)0xa; // '\n'
|
str += ASYNC_SSE_NEW_LINE_CHAR; // '\n'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
str += T_id__;
|
str += T_id__;
|
||||||
str += id;
|
str += id;
|
||||||
str += (char)0xa; // '\n'
|
str += ASYNC_SSE_NEW_LINE_CHAR; // '\n'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event != NULL) {
|
if (event != NULL) {
|
||||||
str += T_event_;
|
str += T_event_;
|
||||||
str += event;
|
str += event;
|
||||||
str += (char)0xa; // '\n'
|
str += ASYNC_SSE_NEW_LINE_CHAR; // '\n'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!message)
|
if (!message)
|
||||||
@@ -95,13 +97,13 @@ static String generateEventMessage(const char* message, const char* event, uint3
|
|||||||
|
|
||||||
str += T_data_;
|
str += T_data_;
|
||||||
str.concat(lineStart, lineEnd - lineStart);
|
str.concat(lineStart, lineEnd - lineStart);
|
||||||
str += 0xa; // \n
|
str += ASYNC_SSE_NEW_LINE_CHAR; // \n
|
||||||
|
|
||||||
lineStart = nextLine;
|
lineStart = nextLine;
|
||||||
} while (lineStart < ((char*)message + messageLen));
|
} while (lineStart < ((char*)message + messageLen));
|
||||||
|
|
||||||
// append another \n to terminate message
|
// append another \n to terminate message
|
||||||
str += 0xa; // '\n'
|
str += ASYNC_SSE_NEW_LINE_CHAR; // '\n'
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user