Permalink
Browse files

replaced 'socket.io' feature with 'nowjs'

  • Loading branch information...
1 parent 763dcc7 commit db3f9222bd088b932d97c4b6e1d324984d6644f6 @kadirpekel committed Aug 26, 2011
Showing with 27 additions and 29 deletions.
  1. +9 −3 README.md
  2. +3 −3 examples/{websockets → now}/app.coffee
  3. +12 −0 examples/now/main.eco
  4. +0 −20 examples/websockets/main.eco
  5. +2 −2 lib/coffeemate.coffee
  6. +1 −1 package.json
View
@@ -34,9 +34,9 @@ mate.get '/greet/:name', ->
@greet_msg = "Hello, #{@req.params.name}"
@render 'main'
-# Stream it
-mate.io.sockets.on 'connection', (socket) ->
- socket.emit 'greet', 'Welcome to coffeemate stream'
+# Remote it
+mate.now.greet = ->
+ console.log 'Hello, World!'
# Listen it
mate.listen 3000
@@ -46,6 +46,12 @@ mate.listen 3000
<!-- layout.eco -->
<html>
<head>
+ <script src="/nowjs/now.js"></script>
+ <script type="text/javascript">
+ now.ready(function () {
+ now.greet();
+ });
+ </script>
</head>
<body>
<%- @include @body %>
@@ -5,7 +5,7 @@ mate.options.renderLayout = no
mate.get '/', ->
@render 'main'
-mate.io.sockets.on 'connection', (socket, i=0) ->
- setInterval (-> socket.emit 'news', "Breaking news #{i++}"), 500
-
+mate.now.greet = ->
+ console.log "Hello World"
+
mate.listen 3000
View
@@ -0,0 +1,12 @@
+<html>
+ <head>
+ <script src="/nowjs/now.js"></script>
+ <script type="text/javascript">
+ now.ready(function () {
+ now.greet();
+ });
+ </script>
+ </head>
+ <body>
+ </body>
+</html>
@@ -1,20 +0,0 @@
-<html>
- <head>
- <script src="/socket.io/socket.io.js"></script>
- <script>
-
- var socket = io.connect('http://localhost:3000');
-
- socket.on('news', function (data) {
- document.getElementById('newsbox').innerHTML += '<p>' + data + '</p>';
- });
-
- </script>
- </head>
- <body>
- <div id="newsbox">
- <h3>News</h3>
-
- </div>
- </body>
-</html>
View
@@ -82,8 +82,8 @@ class Coffeemate extends connect.HTTPServer
@baseUrl = '/'
connect.HTTPServer.call @, []
- # enable socket.io if available
- try @io = require('socket.io').listen @
+ # enable nowjs if available
+ try @now = require('now').initialize(@).now
# This method helps you define sub applications under given base path.
# The context of callback is coffeemate instance itself and any router definition
View
@@ -10,7 +10,7 @@
"dependencies": {
"eco": "1.0.3",
"connect": "1.5.1",
- "socket.io": "0.7.6",
+ "now": "0.7.4",
"coffee-script": "1.1.1"
},
"repository": {

0 comments on commit db3f922

Please sign in to comment.