Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Webapplikationen reloaded mit node.js und HTML5

Webapplikationen reloaded mit node.js und HTML5

Thorsten Rinne

September 07, 2012
Tweet

More Decks by Thorsten Rinne

Other Decks in Programming

Transcript

  1. Thorsten Rinne • 35 Jahre • Diplom-Informatiker (FH) • Senior

    Developer @ Yatego GmbH • Twitter: @ThorstenRinne
  2. Sebastian Springer • 29 Jahre • Diplom-Informatiker (FH) • Senior

    Developer / Team Lead @ Mayflower GmbH • Twitter: @basti_springer
  3. „HTML5 is about moving from documents to applications and from

    hacks to solutions.“ Chris Heilmann (Mozilla) auf Twitter
  4. Schnell installiert: Ubuntu (Linux) $ sudo apt-get install nodejs Homebrew

    (OS X) $ brew install node MacPorts (OS X) $ sudo port install nodejs
  5. $sql = ‘SELECT * FROM users‘; $result = $conn->query($sql); vs.

    var query = ‘SELECT * FROM users‘; db.query(query, function(err, results, fields) {...}; );
  6. Webserver Code var http = require(‘http‘); http.createServer( function(req, res) {

    res.writeHead( 200, {‘Content-Type‘: ‘text/plain‘} ); res.end(‘Hello, World‘); }).listen(1337, ‘127.0.0.1‘);
  7. Bibliotheken als NPM • Socket.IO • Backbone.js • Underscore.js •

    express • Common.js • MySQL, redis, CouchDB
  8. WebSockets if ("WebSocket" in window) { var ws = new

    WebSocket("ws://example.com/service"); ws.onopen = function() { // WebSocket is connected. // You can send data by send() method. ws.send("message to send"); // .... }; ws.onmessage = function (evt) { var received_msg = evt.data; }; ws.onclose = function() { // WebSocket is closed }; } else { // the browser doesn't support WebSockets. }
  9. GET /demo HTTP/1.1 Upgrade: WebSocket Connection: Upgrade Host: example.com Origin:

    http://example.com Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5 Sec-WebSocket-Key2: 12998 5 Y3 1 .P00 ^n:ds[4U HTTP/1.1 101 WebSocket Protocol Handshake Upgrade: WebSocket Connection: Upgrade Sec-WebSocket-Origin: http://example.com Sec-WebSocket-Location: ws://example.com/demo Sec-WebSocket-Protocol: sample 8jKS'y:G*Co,Wxa- Client Server
  10. WebWorker var worker = new Worker('backgroundtask.js'); worker.onmessage = function(event) {

    alert(event.data); }; self.onmessage = function(event) { // Do some heavy work self.postMessage('Hello, Berlin'); } backgroundtask.js main.js
  11. Web Storage ‣„kurzlebige“ Daten ‣sessionStorage Object ‣wird beim Schließen des

    Browsers gelöscht ‣„langlebige“ Daten ‣localStorage Objekt ‣wird nicht beim Schließen des Browsers gelöscht ‣produziert File I/O, läuft synchron Safari/Chrome Firefox IE Opera 2 MB 5 MB ~ 200MB 5 MB 4 MB
  12. Web Storage <p>This page was requested <b> <script> if (!sessionStorage.pageCounter)

    { sessionStorage.setItem('pageCounter',0); } sessionStorage.setItem('pageCounter', parseInt(sessionStorage.pageCounter)+1); document.write(sessionStorage.pageCounter); </script> </b> times.</p> <p> <input value="sessionStorage leeren" type="button" onClick="sessionStorage.clear();location.reload(true);"> <input value="Seite laden" type="button" onClick="location.reload(true);"> </p>
  13. Browser Support WOFF TTF OTF EOT SVG Safari Chrome Firefox

    IE Opera iOS x x x x x x x x x x x x x x x
  14. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do

    eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Multi-column layouts
  15. 28 % 64 % 74 % 70 % 77 %

    87 % IE9 Mobile Safari Safari 6 Firefox 15 Opera 12 Chrome 22 html5test.com
  16. Was uns 2012 noch erwartet... • Internet Explorer 10 mit

    Windows 8 (64% HTML5 Support) • viele neue Chrome- und Firefox-Versionen • Chrome on Android im (Smart)-TV • Safari in Apple TV?
  17. Was wir weggelassen haben ... • Geolocation • WebMessaging •

    WebGL • contenteditable • Drag & Drop • Offline Web Applications • Audio/Video • LESS/SASS für CSS
  18. Kontakt Sebastian Springer sebastian.springer@mayflower.de Mayflower GmbH Mannhardtstr. 6 80538 München

    Deutschland @basti_springer https://github.com/sspringer82 Thorsten Rinne [email protected] Yatego GmbH Kobellstr. 15 80336 München Deutschland @ThorstenRinne https://github.com/thorsten