Permalink
Browse files

add example file with some event listeners

  • Loading branch information...
1 parent 2c59320 commit 229e823557b69b4cab1cc9696c534e1656ac0dde @technoweenie committed Jan 18, 2010
Showing with 24 additions and 0 deletions.
  1. +24 −0 example.js
View
@@ -0,0 +1,24 @@
+var sys = require('sys'),
+ api = require('./lib/api').create(),
+ PORT = 3456
+
+api
+ .addListener('request', function(req, status) {
+ sys.puts(req.method + " " + req.url + ' => ' + status)
+ })
+
+ .addListener('locate', function(user, location) {
+ sys.puts("LOCATE " + user + ' => ' + location)
+ })
+
+ .addListener('list', function(location, users) {
+ sys.puts("LIST " + location + " => " + users.join(", "))
+ })
+
+ .addListener('track', function(user, location) {
+ sys.puts("TRACK " + user + " => " + location)
+ })
+
+api.listen(PORT);
+
+sys.puts("Starting Where's Waldo server on port " + PORT)

0 comments on commit 229e823

Please sign in to comment.