DISQUS

britg: Server Side Javascript Continued – Node.js (plus example)

  • Hagen · 5 months ago
    Nice article!

    But a very bad idea to show HTTP example code completely ignoring request verbs. People will copy that :-/ And don't make people join on GET, use PUT to join, DELETE to unjoin.
  • britg · 5 months ago
    True, I plan to make some updates, the first of which is to use POST on the /join URL and enforce it. Also, I will implement a reaper process to clear stale joins.
  • TJ Holowaychuk · 5 months ago
    check out http://github.com/visionmedia/express/tree/master
    might like ;), I just started it but contribution would be great, building a framework on node.js is sexxxxy
  • britg · 5 months ago
    Very cool, will watch its progress on github :) I like the Sinatra-esque lightweight approach.
  • john · 5 months ago
    Hi! This example does not seem to be working with 2009.06.30 node-0.1.0.tar.gz

    When I call /join?player=john then

    The game lobby has started!
    example.js:28: TypeError: Object [object Object] has no method 'respond'
    server.respond(200, players);
    ^


    But THANKS for putting this blog post out there. Really exciting!
    Best,
    John
  • britg · 5 months ago
    Hey John - from your console output, it looks like you are making requests to the wrong script.

    "example.js:28 ..."

    The name of the script, if you used the same copy from the github repo, should be 'gamelobby.js'

    Let me know if that helps!
  • john · 5 months ago
    Sweet! That works :)

    Thanks britg, very fun stuff! I'm planning to build a small comet server using node.js

    Best,
    John