From a754ce70a420e7f6b4bb3e30fc199554f9d7df93 Mon Sep 17 00:00:00 2001 From: walkor Date: Mon, 1 May 2023 10:12:48 +0800 Subject: [PATCH] fix sse --- Protocols/Http/ServerSentEvents.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Protocols/Http/ServerSentEvents.php b/Protocols/Http/ServerSentEvents.php index 7aeafc70d..a6e9e0d75 100644 --- a/Protocols/Http/ServerSentEvents.php +++ b/Protocols/Http/ServerSentEvents.php @@ -50,15 +50,15 @@ public function __toString() if (isset($data['event'])) { $buffer .= "event: {$data['event']}\n"; } - if (isset($data['data'])) { - $buffer .= 'data: ' . \str_replace("\n", "\ndata: ", $data['data']) . "\n\n"; - } if (isset($data['id'])) { $buffer .= "id: {$data['id']}\n"; } if (isset($data['retry'])) { $buffer .= "retry: {$data['retry']}\n"; } - return $buffer; + if (isset($data['data'])) { + $buffer .= 'data: ' . str_replace("\n", "\ndata: ", $data['data']) . "\n"; + } + return $buffer . "\n"; } } \ No newline at end of file