Skip to content
This repository

Express integration #209

Open
wants to merge 1 commit into from

1 participant

Juuso Haavisto
Juuso Haavisto

Looks like Express 3.0 doesn't work with the old example given out in
readme. This setup works fine - atleast on me.

Juuso Haavisto Express integration fix
Looks like Express 3.0 doesn't work with the old example given out in
readme. This setup works fine - atleast on me.
6e92ea9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 31, 2012
Juuso Haavisto Express integration fix
Looks like Express 3.0 doesn't work with the old example given out in
readme. This setup works fine - atleast on me.
6e92ea9
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 93 additions and 92 deletions. Show diff stats Hide diff stats

  1. 185  readme.md
185  readme.md
Source Rendered
... ...
@@ -1,93 +1,94 @@
1  
-Get NowJS http://www.nowjs.com/
2  
-=========
3  
-
4  
-###NowJS makes realtime web apps really easy.
5  
-
6  
-
7  
-<a href="https://github.com/Flotype/now/">Go to Github</a> or 
8  
-<a href="https://github.com/Flotype/now/tarball/master">Download the master tgz</a>
9  
-
10  
-
11  
-Install From npm
12  
-----------------
13  
-
14  
-`npm install now` or `npm install now -g` to install globally
15  
-
16  
-
17  
-
18  
-NowJS is a Node.js module. The client javascript (now.js) is served by the NowJS server.
19  
-
20  
-
21  
-NowJS uses the excellent <a href="https://github.com/LearnBoost/Socket.IO-node">socket.io</a> and <a href="https://github.com/isaacs/node-proxy">node-proxy</a> libraries.
22  
-
23  
-2 Step Setup
24  
-==============
25  
-
26  
-**1. On the server**
27  
-
28  
-    
29  
-    var httpServer = require('http').createServer(function(req, response){ /* Serve your static files */ })
30  
-    httpServer.listen(8080);
31  
-    
32  
-    var nowjs = require("now");
33  
-    var everyone = nowjs.initialize(httpServer);
34  
-    
35  
-    everyone.now.logStuff = function(msg){
36  
-        console.log(msg);
37  
-    }
38  
-    
39  
-**2. On the client**
40  
-<pre><code>
41  
-&lt;script type="text/javascript" src="http://localhost:8080/nowjs/now.js">&lt;/script>
42  
-
43  
-&lt;script type="text/javascript"&gt;
44  
-  now.ready(function(){
45  
-    // "Hello World!" will print on server
46  
-    now.logStuff("Hello World!");
47  
-  });
48  
-&lt;/script>
49  
-</code></pre>
50  
-
51  
-FAQ
52  
--------
53  
-
54  
-**Q: Can I pass in a callback or closure, for example, if the remote function is asynchronous?**
55  
-
56  
-A: Yes. This is 100% supported
57  
-
58  
-
59  
-**Q: How do I use NowJS with [Express](https://github.com/visionmedia/express)?**
60  
-
61  
-A: Very easily. 
62  
-
63  
-    var app = express.createServer();
64  
-    var server = app.listen(3000);
65  
-    var everyone = require("now").initialize(server);
66  
-
67  
-**Q: How do I disable WebSockets or only use xhr-polling?**
68  
-
69  
-A: You can specifiy exactly which transports to use as an initialization options as follows:
70  
-    
71  
-    var nowjs = require("now");
72  
-    var everyone = nowjs.initialize(yourHttpServer, {socketio: {transports: ['xhr-polling', 'jsonp-polling']}});
73  
-
74  
-
75  
-**Q: Error: " SyntaxError: Unexpected token *" / Can I statically host the now.js file?**
76  
-
77  
-A: On the client side, make sure you link to now.js like this
78  
-
79  
-     <script src="http://myserver:myport/nowjs/now.js"></script>
80  
-
81  
-You do not need to host the file /nowjs/now.js. It is automatically hosted by the NowJS using the http server you pass into the .initialize(...) in your server code. If you choose to host now.js yourself, you can, but **do not use the version in github repo** you MUST save the file at `http://myserver:myport/nowjs/now.js` and host that, because it is automatically configured for your server.
82  
-
83  
-Further Reading
84  
----------------
85  
-
86  
-Now that you have NowJS, try the NowJS [User Manual](http://nowjs.com/doc) and [Quick Chat Example](http://nowjs.com/guide) 
87  
-
88  
-Have more questions? Please contact us:
89  
-Email: team@nowjs.com
90  
-
91  
-IRC: [#nowjs on freenode](http://webchat.freenode.net/?nick=nowjs.&channels=nowjs)
92  
-
  1
+Get NowJS http://www.nowjs.com/
  2
+=========
  3
+
  4
+###NowJS makes realtime web apps really easy.
  5
+
  6
+
  7
+<a href="https://github.com/Flotype/now/">Go to Github</a> or 
  8
+<a href="https://github.com/Flotype/now/tarball/master">Download the master tgz</a>
  9
+
  10
+
  11
+Install From npm
  12
+----------------
  13
+
  14
+`npm install now` or `npm install now -g` to install globally
  15
+
  16
+
  17
+
  18
+NowJS is a Node.js module. The client javascript (now.js) is served by the NowJS server.
  19
+
  20
+
  21
+NowJS uses the excellent <a href="https://github.com/LearnBoost/Socket.IO-node">socket.io</a> and <a href="https://github.com/isaacs/node-proxy">node-proxy</a> libraries.
  22
+
  23
+2 Step Setup
  24
+==============
  25
+
  26
+**1. On the server**
  27
+
  28
+    
  29
+    var httpServer = require('http').createServer(function(req, response){ /* Serve your static files */ })
  30
+    httpServer.listen(8080);
  31
+    
  32
+    var nowjs = require("now");
  33
+    var everyone = nowjs.initialize(httpServer);
  34
+    
  35
+    everyone.now.logStuff = function(msg){
  36
+        console.log(msg);
  37
+    }
  38
+    
  39
+**2. On the client**
  40
+<pre><code>
  41
+&lt;script type="text/javascript" src="http://localhost:8080/nowjs/now.js">&lt;/script>
  42
+
  43
+&lt;script type="text/javascript"&gt;
  44
+  now.ready(function(){
  45
+    // "Hello World!" will print on server
  46
+    now.logStuff("Hello World!");
  47
+  });
  48
+&lt;/script>
  49
+</code></pre>
  50
+
  51
+FAQ
  52
+-------
  53
+
  54
+**Q: Can I pass in a callback or closure, for example, if the remote function is asynchronous?**
  55
+
  56
+A: Yes. This is 100% supported
  57
+
  58
+
  59
+**Q: How do I use NowJS with [Express](https://github.com/visionmedia/express)?**
  60
+
  61
+A: Very easily. 
  62
+
  63
+    var app = express();
  64
+    var server = http.createServer(app);
  65
+    var everyone = require("now").initialize(server);
  66
+	server.listen(3000);
  67
+
  68
+**Q: How do I disable WebSockets or only use xhr-polling?**
  69
+
  70
+A: You can specifiy exactly which transports to use as an initialization options as follows:
  71
+    
  72
+    var nowjs = require("now");
  73
+    var everyone = nowjs.initialize(yourHttpServer, {socketio: {transports: ['xhr-polling', 'jsonp-polling']}});
  74
+
  75
+
  76
+**Q: Error: " SyntaxError: Unexpected token *" / Can I statically host the now.js file?**
  77
+
  78
+A: On the client side, make sure you link to now.js like this
  79
+
  80
+     <script src="http://myserver:myport/nowjs/now.js"></script>
  81
+
  82
+You do not need to host the file /nowjs/now.js. It is automatically hosted by the NowJS using the http server you pass into the .initialize(...) in your server code. If you choose to host now.js yourself, you can, but **do not use the version in github repo** you MUST save the file at `http://myserver:myport/nowjs/now.js` and host that, because it is automatically configured for your server.
  83
+
  84
+Further Reading
  85
+---------------
  86
+
  87
+Now that you have NowJS, try the NowJS [User Manual](http://nowjs.com/doc) and [Quick Chat Example](http://nowjs.com/guide) 
  88
+
  89
+Have more questions? Please contact us:
  90
+Email: team@nowjs.com
  91
+
  92
+IRC: [#nowjs on freenode](http://webchat.freenode.net/?nick=nowjs.&channels=nowjs)
  93
+
93 94
 Twitter: [@NowJSTeam](http://twitter.com/nowjsteam)
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.