king
Version:
A powerful server infrastructure management platform - "The King of your Nodes"
65 lines (52 loc) • 1.74 kB
JavaScript
// Generated by CoffeeScript 1.6.3
var Base, ServantClient, helper, upnode,
__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; };
Base = require("../common/base");
helper = require("../common/helper");
upnode = require("upnode");
module.exports = ServantClient = (function(_super) {
__extends(ServantClient, _super);
ServantClient.prototype.name = 'ServantClient';
function ServantClient(king, d) {
this.king = king;
this.d = d;
this.id = "...";
this.remote = null;
helper.bindAll(this);
this.api = this.makeApi();
this.d.on('remote', this.onRemote);
this.d.on('end', this.onEnd);
}
ServantClient.prototype.onRemote = function(remote) {
this.id = remote.id;
this.log("connected");
this.remote = remote;
return this.king.servants.add(this);
};
ServantClient.prototype.onEnd = function() {
this.log("dismissed...");
return this.king.servants.remove(this);
};
ServantClient.prototype.serialize = function() {
var _ref;
return {
id: this.id,
capabilities: (_ref = this.remote) != null ? _ref.capabilities : void 0
};
};
ServantClient.prototype.makeApi = function() {
var _this = this;
return {
report: function() {
return _this.log("data reported", Array.prototype.slice.call(arguments));
},
config: {
get: function() {
return _this.log("get...");
}
}
};
};
return ServantClient;
})(Base);