0

I have a PHP cron job that checks for new emails once every minute. I can fetch the IP addresses for every account from my database via the authentication log no problem. What I'm not sure about is how to send the Server Sent DOM event to specific IP addresses.

The basic...

<?php
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
$ip = '127.0.0.1';
$message = 'Example Message.';
?>

This is NOT something that can be initiated from the client at all since it is a cron job. It is perfectly okay if one/any/all account holders don't have a browser open and ready to accept the notification, they are aware of that requirement.

This question is explicitly how to send a signal from the server to the client and has nothing to do with the client other then sending a signal to their IP address.

4

2 回答 2

1

我只需要使用fsockopen()...

<?php
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
$ip = '127.0.0.1';
$message = 'Example Message.';
$result1 = fsockopen($ip,80,200,$message,30);
?>
于 2013-10-03T16:12:17.230 回答
0

您无法启动从 Web 服务器到客户端的任何通信。客户端必须首先发送一个请求作为响应,您的服务器可能会发送所需的信息。

于 2013-10-03T16:09:51.727 回答