Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 85 lines (50 sloc) 2.498 kb
e731d4f @ericz adding readme
ericz authored
1 Get NowJS http://www.nowjs.com/
2 =========
57d214a @ericz Edited readme.md via GitHub
ericz authored
3
4 NowJS makes realtime web apps really easy.
e731d4f @ericz adding readme
ericz authored
5
6
7 <a href="https://github.com/Flotype/now/">Go to Github</a> or
57d214a @ericz Edited readme.md via GitHub
ericz authored
8 <a href="https://github.com/Flotype/now/tarball/master">Download the master tgz</a>
e731d4f @ericz adding readme
ericz authored
9
10
11 Install From npm
12 ----------------
13
57d214a @ericz Edited readme.md via GitHub
ericz authored
14 `npm install now` or `npm install now -g` to install globally
e731d4f @ericz adding readme
ericz authored
15
16
17
57d214a @ericz Edited readme.md via GitHub
ericz authored
18 NowJS is a Node.js module. The client javascript (now.js) is served by the NowJS server.
19
e731d4f @ericz adding readme
ericz authored
20
57d214a @ericz Edited readme.md via GitHub
ericz authored
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.
e731d4f @ericz adding readme
ericz authored
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
66
67 **Q: Error: " SyntaxError: Unexpected token *" / Can I statically host the now.js file?**
68
69 A: On the client side, make sure you link to now.js like this
70
71 <script src="http://myserver:myport/nowjs/now.js"></script>
72
73 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.
74
75 Further Reading
76 ---------------
77
78 Now that you have NowJS, try the NowJS [User Manual](http://nowjs.com/doc) and [Quick Chat Example](http://nowjs.com/guide)
79
80 Have more questions? Please contact us:
81 Email: team@nowjs.com
82
83 IRC: #nowjs on freenode
84
85 Twitter: @NowJSTeam
Something went wrong with that request. Please try again.