Slightly clean up Connection
This commit is contained in:
parent
1c8e84cfb2
commit
ba295e9642
|
@ -13,11 +13,6 @@ var EventEmitter = require('events').EventEmitter;
|
|||
var Logger = require('./logger'),
|
||||
Utils = require('./utils');
|
||||
|
||||
// The Connection class represents the interface to
|
||||
// a specific group of hardware devices. Examples would be an
|
||||
// Arduino, a Sphero, or an ARDrone.
|
||||
var Connection;
|
||||
|
||||
// Public: Creates a new Connection
|
||||
//
|
||||
// opts - hash of acceptable params:
|
||||
|
@ -28,14 +23,10 @@ var Connection;
|
|||
// port - string port to use for the Connection
|
||||
//
|
||||
// Returns the newly set-up connection
|
||||
module.exports = Connection = function Connection(opts) {
|
||||
if (opts == null) {
|
||||
opts = {};
|
||||
}
|
||||
var Connection = module.exports = function Connection(opts) {
|
||||
opts = opts || {};
|
||||
|
||||
if (opts.id == null) {
|
||||
opts.id = Math.floor(Math.random() * 10000);
|
||||
}
|
||||
opts.id = opts.id || Math.floor(Math.random() * 10000);
|
||||
|
||||
this.connect = this.connect.bind(this);
|
||||
|
||||
|
@ -101,12 +92,7 @@ Connection.prototype.initAdaptor = function(opts) {
|
|||
//
|
||||
// Returns nothing
|
||||
Connection.prototype.halt = function(callback) {
|
||||
var msg = "Halting adaptor " + this.name;
|
||||
|
||||
if (this.port != null) {
|
||||
msg += " on port " + this.port;
|
||||
}
|
||||
|
||||
var msg = this._logstring("Halting adaptor");
|
||||
Logger.info(msg);
|
||||
return this.disconnect(callback);
|
||||
};
|
||||
|
|
|
@ -113,7 +113,7 @@ describe("Connection", function() {
|
|||
});
|
||||
|
||||
it("logs that it's halting the adaptor", function() {
|
||||
var message = "Halting adaptor loopback on port /dev/null";
|
||||
var message = "Halting adaptor 'loopback' on port /dev/null.";
|
||||
expect(Logger.info).to.be.calledWith(message);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue