我想用CI创建实时应用程序。 所以我写控制器(CI)的一些代码如何在codeigniter中实现服务器发送的事件?
这里是我的代码:
$this->output->set_content_type('text/event-stream');
$this->output->set_header('Cache-Control: no-cache');
$time = date('r');
$output="data: The server time is: {$time}\n\n";
flush();
但是,我得到这个错误:
EventSource's response has a MIME type ("text/html") that is not "text/event-stream". Aborting the connection.
想法?
更改MIME类型 –