Your SlideShare is downloading. ×
0
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
NodeJS "Web en tiempo real"
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

NodeJS "Web en tiempo real"

1,946

Published on

La presentación sobre Node JS que hice para el Meetup de Lenguajes Dinámicos.

La presentación sobre Node JS que hice para el Meetup de Lenguajes Dinámicos.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,946
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
35
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Web en tiempo real
  • 2. EVENTED I/O
  • 3. MODELO TRADICIONAL Server DB
  • 4. MODELO TRADICIONAL Server DB
  • 5. MODELO TRADICIONAL Server DB
  • 6. MODELO C/EVENTOS Server DB
  • 7. MODELO C/EVENTOS Server DB
  • 8. MODELO C/EVENTOS Main Loop DB
  • 9. TwistedEventMachine
  • 10. Evented I/O for V8 JavaScript.
  • 11. INSTALACIÓN$ curl -O http://nodejs.org/dist/node-v0.2.5.tar.gz # http://nodejs.org/#download$ tar xvf node-v0.2.5.tar.gz$ cd node-v0.2.5$ ./configure$ make$ sudo make install$ node --version # => v0.2.5$ node> // modo interactivo> [Ctrl+C]
  • 12. DOCUMENTACIÓN http://nodejs.org/api.html
  • 13. ESTRUCTURAFramework de bajo nivel
  • 14. SERVIDOR WEB1 var http = require(http);23 http.createServer(function (req, res) {4 res.writeHead(200, {Content-Type: text/plain});5 res.end(Hello Worldn);6 }).listen(8124, "127.0.0.1");78 console.log(Server running at http://127.0.0.1:8124/);
  • 15. EXPRESS 1 2 var app = express.createServer(); Node’s Sinatra 3 app.get(/, function(req, res){ 4 res.send(Hello World); 5 });http://expressjs.com/ 6 7 app.listen(3000);
  • 16. SISTEMA DE PAQUETES
  • 17. NODE PACKAGE MANAGER http://npmjs.org/
  • 18. WEB SOCKETS
  • 19. CONEXIÓN PERSISTENTE
  • 20. BAJO NIVEL 1 var sys = require(sys), 2 WebSocket = require(../websockets); 3 4 function TimeJS () { 5 var self = this; 6 7 this.websocket = new WebSocket.Server({resource: /time, host: localhost}); 8 this.connections = new Array(); 910 this.websocket.addListener(connect, function (server, connection) {11 self.connections[connection.socket.fd] = "";12 });13 this.websocket.addListener(disconnect, function (server, connection) {14 clearInterval(self.connections[connection.socket.fd]);15 self.connections.splice(self.connections.indexOf(connection.socket.fd), 1);16 });17 this.websocket.addListener(receive, function (data, connection) {18 if (data == start) {19 self.connections[connection.socket.fd] = setInterval(function () {20 connection.write(JSON.stringify({time: new Date().toString()}));21 }, 1000);22 }23 });24 }2526 new TimeJS(); https://github.com/jackyyll/nodejs-websockets
  • 21. Faye is an easy-to-use publish-subscribe messaging system based on the Bayeux protocol.It provides message servers for Node.js and Rack,and clients for use in Node and Ruby programs http://faye.jcoglan.com
  • 22. INICIAR UN SERVIDOR1 var Faye = require(faye),2 server = new Faye.NodeAdapter({mount: /});34 server.listen(8000);
  • 23. CREAR UN CLIENTE5 var client = new Faye.Client(http://localhost:8000/);67 client.subscribe(/messages, function(message) {8 alert(Got a message: + message.text);9 });
  • 24. ENVIAR MENSAJES 10 client.publish(/messages, { 11 text: Hello world 12 });
  • 25. MAS SIMPLEWeb Sockets as a Service http://pusherapp.com/
  • 26. (DEMO)https://github.com/sagmor/mapsketcher
  • 27. Fotos: sjunnesson, atranman, denial_land, moriza, ghero79 @ Flickr

×