HTML5 Server-Sent Events

-- HTML5 2012. 7. 18. 20:35
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Conventional web applications generate events which are dispatched to the web server. For example a simple click on a link requests a new page from the server. The type of events which are flowing from web browser to the web server may be called client-sent events.

Along with HTML5, WHATWGWeb Applications 1.0 introduces events which flow from web server to the web browsers and they are called Server-Sent Events (SSE). Using SSE you can push DOM events continously from your web server to the visitor's browser.

The event streaming approach opens a persistent connection to the server, sending data to the client when new information is available, eliminating the need for continuous polling.

Server-sent events standardizes how we stream data from the server to the client.
 

To use Server-Sent Events in a web application, you would need to add an <eventsource> element to the document. The src attribute of <eventsource> element should point to an URL which should provide a persistent HTTP connection that sends a data stream containing the events.

The URL would point to a PHP, PERL or any Python script which would take care of sending event data consistently. Following is a simple example of web application which would expect server time.
 

<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
/- Define event handling logic here *-
</script>
</head>
<body>
<div id="sse">
  
<eventsource src="/cgi-bin/ticker.cgi" />
</div>
<div id="ticker">
   <TIME>
</div>
</body>
</html>


여기에 powershell같은 것들이 동작을 할 지 모르겠는데, 나중에 한번 작성하기로 하겠다.

'-- HTML5' 카테고리의 다른 글

Semantic HTML5 Page Layout  (0) 2012.09.06
HTML5 Web Socket  (0) 2012.07.30
HTML5 Web Storage, Web SQL Database  (0) 2012.07.18
HTML5 autofocus, required  (0) 2012.07.18
HTML5 IE를 위한 javascript  (0) 2012.07.17
posted by 어린왕자악꿍