1 / 19

Easy Realtime

Easy Realtime. With NowJS + Node.js. Why Node.js?. Why Node.js?. Asynchronous I/O. Why Node.js?. Evented Requests. Why Node.js?. Shared memory inter-request communication. Why Node.js?. Javascript. Perfect for realtime !. What is NowJS.

ollie
Télécharger la présentation

Easy Realtime

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Easy Realtime With NowJS + Node.js

  2. Why Node.js?

  3. Why Node.js? Asynchronous I/O

  4. Why Node.js? Evented Requests

  5. Why Node.js? Shared memory inter-request communication

  6. Why Node.js? Javascript

  7. Perfect for realtime!

  8. What is NowJS

  9. var everyone =require("now").initialize(httpServer); everyone.now.myFunc = function(callback){ • callback('hi'); } What is NowJS <script> now.myFunc(function(data){ alert(data); }); </script>

  10. What is NowJS

  11. What is NowJS • Bidirectional realtime • Automatically synced namespace `now` • Groups • Ready to scale • More than a socket: optimized for realtime web applications • No more JSON, parsing, routing, COMET, xhr • Depends on socket.io / node-proxy

  12. Let’s make a chat room • varserver = require("http").createServer(); • var everyone =require("now").initialize(httpServer); • everyone.now.distributeMessage = function(message) { • everyone.now.receiveMessage(this.now.name, message); • }; • server.listen(8080);

  13. Let’s make a chat room • varserver = require("http").createServer(); • var everyone =require("now").initialize(server); • everyone.now.distributeMessage = function(message) { • everyone.now.receiveMessage(this.now.name, message); • }; • server.listen(8080); server.js # our node.js server

  14. Let’s make a chat room $ -> now.receiveMessage = (name, message) ->     $("#messages").append("<br>"+ name +": "+ message)   $("#send-button").click -> now.distributeMessage($("#text-input").val());     $("#text-input").val(""); now.name = prompt("What's your name?", ""); chat.js.coffee# our frontend js

  15. Let’s make a chat room <h1>Chat#index</h1> <divid="messages"></div> <inputtype="text"id="text-input"> <inputtype="button"value="Send"id="send-button"> index.html.erb# our frontend html

  16. Let’s make a chat room

  17. Let’s make a chat room

  18. Let’s make a chat room

  19. @nowjsteam @reallyez team@nowjs.com

More Related