Horje

Example of Server-Sent Events - One Way Messaging

To work with server-sent, we need a server which can send data updates to the web browser. For this, we need to create a file in ASP, PHP or any dynamic language. Following is the example to show the server updates: ServerUpdate.php:

ServerUpdate.php
Example: HTML
    <?php  
     header('Content-Type: text/event-stream');  
     header('Cache-Control: no-cache');  
    /Get the current time of server  
      $time = date('r');  
     echo "data: The Current Server time is: {$time}\n\n";  
     flush();  
     ?>  




Single Articles
Example of Server-Sent Events - One Way MessagingHTML SSE API
Code Explanation: Server-Sent Events - One Way MessagingHTML SSE API


Related Articles
What is HTML SSE API HTML SSE API
How to add Server-Sent Events - One Way Messaging HTML SSE API
What types of browsers will support HTML SSE API HTML SSE API
How to Receive Server-Sent Event Notifications HTML SSE API
How to Check Server-Sent Events Support HTML SSE API
What is Server-Side Code Example HTML SSE API
What are The EventSource Object HTML SSE API

Type:
Html
Category:
Web Tutorial
Sub Category:
HTML SSE API
Uploaded by:
Admin