Sha256: 3917a4854ac14a0d68e8f339257292e26f66507799c7ca9970a19f1bd8e4a0f6

Contents?: true

Size: 793 Bytes

Versions: 1

Compression:

Stored size: 793 Bytes

Contents

var posix = require('posix'),
    path  = require('path'),
    sys   = require('sys'), 
    http  = require('http')
    faye  = require('./faye');

var PUBLIC_DIR = path.dirname(__filename) + '/../shared/public',
    comet      = new faye.NodeAdapter({mount: '/comet', timeout: 45}),
    
    port       = process.ARGV[2] || '8000';

sys.puts('Listening on ' + port);

http.createServer(function(request, response) {
  sys.puts(request.method + ' ' + request.url);
  if (comet.call(request, response)) return;
  
  var path = (request.url === '/') ? '/index.html' : request.url;
  
  posix.cat(PUBLIC_DIR + path).addCallback(function(content) {
    response.sendHeader(200, {'Content-Type': 'text/html'});
    response.sendBody(content);
    response.finish();
  });
}).listen(Number(port));

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
faye-0.2.2 examples/node/app.js