aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2014-02-24 15:43:58 +0100
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2014-02-24 15:43:58 +0100
commitaa43544fea14729352c1f0fb431bb2f5b6d9897a (patch)
tree29e7254dff0bdeabdf74d1edb0fb7533c7296950
parent5fd4e26e88592bc78627de77b8aac221323b402e (diff)
downloadEventsource-aa43544fea14729352c1f0fb431bb2f5b6d9897a.zip
Eventsource-aa43544fea14729352c1f0fb431bb2f5b6d9897a.tar.gz
Eventsource-aa43544fea14729352c1f0fb431bb2f5b6d9897a.tar.bz2
Add syntax highlighting.
-rw-r--r--README.md56
1 files changed, 30 insertions, 26 deletions
diff --git a/README.md b/README.md
index d6dba88..9d5699f 100644
--- a/README.md
+++ b/README.md
@@ -15,44 +15,48 @@ We propose as a quick overview to send an unlimited number of events from the
server to the client. The client will display all received events. Thus, in
`Server.php`:
- $server = new Hoa\Eventsource\Server();
+```php
+$server = new Hoa\Eventsource\Server();
- while(true) {
+while(true) {
- // “tick” is the event name.
- $server->tick->send(time());
- sleep(1);
- }
+ // “tick” is the event name.
+ $server->tick->send(time());
+ sleep(1);
+}
+```
And in `index.html`, our client:
- <pre id="output"></pre>
- <script>
- var output = document.getElementById('output');
+```html
+<pre id="output"></pre>
+<script>
+var output = document.getElementById('output');
- try {
+try {
- var source = new EventSource('Server.php');
- source.onopen = function ( ) {
+ var source = new EventSource('Server.php');
+ source.onopen = function ( ) {
- output.appendChild(document.createElement('hr'));
+ output.appendChild(document.createElement('hr'));
- return;
- };
- source.addEventListener('tick', function ( evt ) {
+ return;
+ };
+ source.addEventListener('tick', function ( evt ) {
- var samp = document.createElement('samp');
- samp.innerHTML = evt.data + '\n';
- output.appendChild(samp);
+ var samp = document.createElement('samp');
+ samp.innerHTML = evt.data + '\n';
+ output.appendChild(samp);
- return;
- });
- }
- catch ( e ) {
+ return;
+ });
+}
+catch ( e ) {
- console.log(e);
- }
- </script>
+ console.log(e);
+}
+</script>
+```
Start your HTTP server and then open `index.html`.