![]() ![]() ![]() The onmessage handler is called if no event name is specified for a message. If this is specified, an event will be dispatched on the browser to the listener for the specified event name the website source code should use addEventListener() to listen for named events. client closes the page).Įach message received has some combination of the following fields, one per line: eventĪ string identifying the type of event described. To break the loop if the connection has been closed (e.g. The loop will keep running independent of the connection status, so a check is included At random intervals, a simple message (with no event type) is sent. Each event's data is a JSON object containing the ISO 8601 timestamp corresponding to the time at which the event was generated. The code above generates an event every second, with the event type "ping". Php date_default_timezone_set ( "America/New_York" ) header ( "Cache-Control: no-store" ) header ( "Content-Type: text/event-stream" ) $counter = rand ( 1, 10 ) while ( true ) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |