-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
45 lines (37 loc) · 1.29 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!doctype html>
<html>
<head>
<script src="poor_modules/poor-module.js"></script>
<script src="underscore.js"></script>
<script>poorModule("underscore", function () { return _ })</script>
<script src="rpc.js"></script>
<script src="red-yarn.js"></script>
<script src="client-example.js"></script>
</head>
<body>
<h1>red yarn</h1> <i>abstracted client server communication</i>
<a href="http://github.com/drewlesueur/red-yarn">Source on github</a>
<br />
Look at console to see results
<h2>Server Code</h2>
<pre>
RedYarn = poorModule "red-yarn"
server = RedYarn.createServer "drewl.us:9002", (err, client) ->
client.call "getClientTime", (err, time) ->
console.log "a client conntected and his time is #{time}"
server.getServerTime = (cb) ->
cb null, Date.now()
</pre>
<h2>Client code</h2>
<pre>
RedYarn = poorModule "red-yarn"
client = RedYarn.createClient "drewl.us:9002", (err, server) ->
server.call "getServerTime", (err, time) ->
console.log "server time is #{time}"
client.getClientTime = (cb) ->
cb null, Date.now()
console.log "the server got my time!"
</pre>
by <a href="http://twitter.com/drewlesueur">Drew LeSueur</a>
</body>
</html>