cylon/lib/adaptor.js

54 lines
1.4 KiB
JavaScript
Raw Normal View History

2013-10-25 05:25:42 +08:00
/*
* adaptor
* cylonjs.com
*
* Copyright (c) 2013 The Hybrid Group
* Licensed under the Apache 2.0 license.
*/
(function() {
'use strict';
var namespace,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
2013-10-25 05:25:42 +08:00
2013-11-12 00:28:37 +08:00
namespace = require('node-namespace');
2013-10-25 05:25:42 +08:00
require('./basestar');
namespace('Cylon', function() {
return this.Adaptor = (function(_super) {
__extends(Adaptor, _super);
2013-11-12 00:28:37 +08:00
function Adaptor(opts) {
2013-12-16 11:14:39 +08:00
if (opts == null) {
opts = {};
}
this.self = this;
2013-11-12 00:28:37 +08:00
this.name = opts.name;
this.connection = opts.connection;
this.commandList = [];
2013-11-12 00:28:37 +08:00
}
2013-10-25 05:25:42 +08:00
2013-11-12 00:28:37 +08:00
Adaptor.prototype.commands = function() {
return this.commandList;
};
Adaptor.prototype.connect = function(callback) {
Logger.info("Connecting to adaptor '" + this.name + "'...");
callback(null);
return this.connection.emit('connect');
};
Adaptor.prototype.disconnect = function() {
return Logger.info("Disconnecting from adaptor '" + this.name + "'...");
2013-11-12 00:28:37 +08:00
};
2013-10-25 05:25:42 +08:00
2013-11-12 00:28:37 +08:00
return Adaptor;
})(Cylon.Basestar);
2013-11-12 00:28:37 +08:00
});
2013-10-25 05:25:42 +08:00
}).call(this);