text: // Generated by CoffeeScript 1.6.2
  var sessionHandler, sockjs, wrapSession;
  
  sockjs = require('sockjs');
  
  sessionHandler = require('./session').handler;
  
  wrapSession = function(conn) {
    conn.abort = function() {
      return this.close();
    };
    conn.stop = function() {
      return this.end();
    };
    conn.send = function(response) {
      return this.write(JSON.stringify(response));
    };
    conn.ready = function() {
      return this.readyState === 1;
    };
    conn.on('data', function(data) {
      return this.emit('message', JSON.parse(data));
    });
    conn.address = conn.remoteAddress;
    return conn;
  };
  
  exports.attach = function(server, createAgent, options) {
    var sjsServer;
  
    options.prefix || (options.prefix = "/sockjs");
    sjsServer = sockjs.createServer(options);
    sjsServer.on('connection', function(conn) {
      return sessionHandler(wrapSession(conn), createAgent);
    });
    return sjsServer.installHandlers(server);
  };
  