Skip to content

Commit

Permalink
some delinting
Browse files Browse the repository at this point in the history
  • Loading branch information
dannycoates committed Dec 8, 2010
1 parent 9b25788 commit 0e1ec59
Show file tree
Hide file tree
Showing 4 changed files with 410 additions and 371 deletions.
6 changes: 6 additions & 0 deletions lib/callback.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@


/**
* Create a callback container
* @return {Object} that wraps callbacks and returns a one-time id.
*/
exports.create = function() {
var lastId = 1,
callbacks = {};
Expand Down
25 changes: 13 additions & 12 deletions lib/debug-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var Http = require('http'),
paperboy = require('../vendor/paperboy'),
debugr = require('./debugger'),
Session = require('./session');

var WEBROOT = path.join(__dirname, '../front-end');
function staticFile(req, res) {
req.url = req.url.replace(/^\/debug/, '/');
Expand All @@ -14,7 +14,7 @@ function staticFile(req, res) {

function override(options, defaults) {
var result = {};
Object.keys(defaults).forEach(function (key) {
Object.keys(defaults).forEach(function(key) {
result[key] = options[key] || defaults[key];
});
return result;
Expand All @@ -27,31 +27,32 @@ exports.create = function(options, config) {
wsServer = WebSocket.createServer({server: httpServer}),
debugPort = config.debugPort.toString();

wsServer.on('connection', function (conn) {
var port = parseInt((/\?port=(\d+)/.exec(conn._req.url) || [null,debugPort])[1], 10),
wsServer.on('connection', function(conn) {
var port =
parseInt((/\?port=(\d+)/.exec(conn._req.url) || [null, debugPort])[1], 10),
session = Session.create(conn, debugr, port, config);

conn.on('message', function (data) {
conn.on('message', function(data) {
session.handleRequest(data);
});
conn.on('close', function () {
conn.on('close', function() {
session.close();
console.log('connection closed');
});
});

wsServer.listen(settings.webPort);

wsServer.on('listening', function(){
wsServer.on('listening', function() {
console.log(
'visit http://0.0.0.0:' +
settings.webPort +
'/debug?port=5858 to start debugging');
'visit http://0.0.0.0:' +
settings.webPort +
'/debug?port=5858 to start debugging');
});

return Object.create(EventEmitter.prototype, {
close: {
value: function ()
value: function()
{
if (wsServer) {
wsServer.close();
Expand All @@ -60,7 +61,7 @@ exports.create = function(options, config) {
}
},
webPort: {
get: function () { return settings.webPort; }
get: function() { return settings.webPort; }
}
});
};
28 changes: 14 additions & 14 deletions lib/debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function makeMessage() {
///////////////////////////////////////////////////////////
// exports

exports.attachDebugger = function (port) {
exports.attachDebugger = function(port) {
var connected = false,
debugBuffer = '',
msg = false,
Expand Down Expand Up @@ -68,20 +68,20 @@ exports.attachDebugger = function (port) {

debugr = Object.create(EventEmitter.prototype, {
send: {
value: function (data)
value: function(data)
{
if (connected) {
conn.write('Content-Length: ' + data.length + '\r\n\r\n' + data);
}
}
},
request: {
value: function (command, params, callback) {
value: function(command, params, callback) {
var msg = {
seq: 0,
type: 'request',
command: command
};
seq: 0,
type: 'request',
command: command
};
if (typeof callback == 'function') {
msg.seq = callbackHandler.wrap(callback);
}
Expand All @@ -94,7 +94,7 @@ exports.attachDebugger = function (port) {
}
},
close: {
value: function ()
value: function()
{
conn.end();
}
Expand All @@ -104,25 +104,25 @@ exports.attachDebugger = function (port) {
}
});

conn.on('connect', function () {
conn.on('connect', function() {
connected = true;
debugr.emit('connect');
});

conn.on('data', function (data) {
conn.on('data', function(data) {
debugBuffer += data;
parse();
});

conn.on('error', function(e) {
debugr.emit('error', e);
});

conn.on('end', function () {
conn.on('end', function() {
debugr.close();
});
conn.on('close', function () {

conn.on('close', function() {
connected = false;
debugr.emit('close');
});
Expand Down
Loading

0 comments on commit 0e1ec59

Please sign in to comment.