Skip to content
This repository
Newer
Older
100644 92 lines (54 sloc) 2.897 kb
2035dc6f »
2011-09-26 change references to nowjs.org to nowjs.com
1 Get NowJS http://www.nowjs.com/
e731d4fa »
2011-07-22 adding readme
2 =========
57d214aa »
2011-07-22 Edited readme.md via GitHub
3
cca8bfd0 »
2011-07-22 Edited readme.md via GitHub
4 ###NowJS makes realtime web apps really easy.
e731d4fa »
2011-07-22 adding readme
5
6
7 <a href="https://github.com/Flotype/now/">Go to Github</a> or
57d214aa »
2011-07-22 Edited readme.md via GitHub
8 <a href="https://github.com/Flotype/now/tarball/master">Download the master tgz</a>
e731d4fa »
2011-07-22 adding readme
9
10
11 Install From npm
12 ----------------
13
57d214aa »
2011-07-22 Edited readme.md via GitHub
14 `npm install now` or `npm install now -g` to install globally
e731d4fa »
2011-07-22 adding readme
15
16
17
57d214aa »
2011-07-22 Edited readme.md via GitHub
18 NowJS is a Node.js module. The client javascript (now.js) is served by the NowJS server.
19
e731d4fa »
2011-07-22 adding readme
20
57d214aa »
2011-07-22 Edited readme.md via GitHub
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.
e731d4fa »
2011-07-22 adding readme
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 var app = express.createServer();
63 app.listen(3000);
64 var everyone = require("now").initialize(app);
65
7fac289a »
2011-09-19 Add transports to FAQ
66 **Q: How do I disable WebSockets or only use xhr-polling?**
67
68 A: You can specifiy exactly which transports to use as an initialization options as follows:
1b8c4d1a »
2011-09-19 Edited readme.md via GitHub
69
7fac289a »
2011-09-19 Add transports to FAQ
70 var nowjs = require("now");
71 var everyone = nowjs.initialize(yourHttpServer, {socketio: {transports: ['xhr-polling', 'jsonp-polling']}});
72
e731d4fa »
2011-07-22 adding readme
73
74 **Q: Error: " SyntaxError: Unexpected token *" / Can I statically host the now.js file?**
75
76 A: On the client side, make sure you link to now.js like this
77
78 <script src="http://myserver:myport/nowjs/now.js"></script>
79
80 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.
81
82 Further Reading
83 ---------------
84
2035dc6f »
2011-09-26 change references to nowjs.org to nowjs.com
85 Now that you have NowJS, try the NowJS [User Manual](http://nowjs.com/doc) and [Quick Chat Example](http://nowjs.com/guide)
e731d4fa »
2011-07-22 adding readme
86
87 Have more questions? Please contact us:
2035dc6f »
2011-09-26 change references to nowjs.org to nowjs.com
88 Email: team@nowjs.com
e731d4fa »
2011-07-22 adding readme
89
4a3f4402 »
2011-07-22 Edited readme.md via GitHub
90 IRC: [#nowjs on freenode](http://webchat.freenode.net/?nick=nowjs.&channels=nowjs)
e731d4fa »
2011-07-22 adding readme
91
4a3f4402 »
2011-07-22 Edited readme.md via GitHub
92 Twitter: [@NowJSTeam](http://twitter.com/nowjsteam)
Something went wrong with that request. Please try again.