I'm wondering the script below that I grabbed from Swoole website creates new connection or thread every couple of seconds and I don't like it. While yours is not which is I'm looking for. Sorry but this is not really an issue. Just want to ask or mentor me what's the idea to prevent SSE from creating new connection every couple of seconds. I want SSE to maintain that connection until that client closes or refresh the browser. Thank you in advance.
while(true):
$data = "event: ping\n";
$response->write($data);
$curDate = date(DATE_ISO8601);
$data = 'data: {"time": "' . $curDate . '"}';
$data .= "\n\n";
$response->write($data);
$counter--;
if (!$counter) {
$data = 'data: This is a message at time ' . $curDate . "\n\n";
$response->end($data);
break;
}
Coroutine::sleep(3);
endwhile;

I'm wondering the script below that I grabbed from Swoole website creates new connection or thread every couple of seconds and I don't like it. While yours is not which is I'm looking for. Sorry but this is not really an issue. Just want to ask or mentor me what's the idea to prevent SSE from creating new connection every couple of seconds. I want SSE to maintain that connection until that client closes or refresh the browser. Thank you in advance.