More hogfather structure.
This commit is contained in:
@@ -21,13 +21,22 @@
|
|||||||
* @constructor
|
* @constructor
|
||||||
* @param {Cosmopolite} cosmo
|
* @param {Cosmopolite} cosmo
|
||||||
* @param {string} name
|
* @param {string} name
|
||||||
* @param {function()} onReady
|
|
||||||
*/
|
*/
|
||||||
var Hogfather = function(cosmo, name, onReady) {
|
var Hogfather = function(cosmo, name) {
|
||||||
cosmo.getProfile().then(function(profile_id) {
|
this.cosmo_ = cosmo;
|
||||||
this.prefix_ = '/hogfather/' + profile_id + '/' + name + '/';
|
this.name_ = name;
|
||||||
onReady();
|
|
||||||
}.bind(this));
|
this.cosmo_.getProfile().then(this.onProfile_.bind(this));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} profile_id
|
||||||
|
*/
|
||||||
|
Hogfather.prototype.onProfile_ = function(profile_id) {
|
||||||
|
this.prefix_ = '/hogfather/' + profile_id + '/' + this.name_ + '/';
|
||||||
|
this.cosmo_.subscribe(this.prefix_ + 'control');
|
||||||
|
console.log(this.prefix_);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -949,10 +949,14 @@ QUnit.module('Hogfather');
|
|||||||
|
|
||||||
QUnit.asyncTest('Construct/shutdown', function(assert) {
|
QUnit.asyncTest('Construct/shutdown', function(assert) {
|
||||||
assert.expect(4);
|
assert.expect(4);
|
||||||
|
|
||||||
var cosmo = new Cosmopolite(null, randstring());
|
var cosmo = new Cosmopolite(null, randstring());
|
||||||
assert.ok(true, 'new Cosmopolite() succeeds');
|
assert.ok(true, 'new Cosmopolite() succeeds');
|
||||||
|
|
||||||
var hogfather = new Hogfather(cosmo, randstring(), function() {
|
var hogfather = new Hogfather(cosmo, randstring());
|
||||||
|
assert.ok(true, 'new Hogfather()) succeeds');
|
||||||
|
|
||||||
|
window.setTimeout(function() {
|
||||||
hogfather.shutdown();
|
hogfather.shutdown();
|
||||||
assert.ok(true, 'Hogfather.shutdown() succeeds');
|
assert.ok(true, 'Hogfather.shutdown() succeeds');
|
||||||
|
|
||||||
@@ -960,6 +964,6 @@ QUnit.asyncTest('Construct/shutdown', function(assert) {
|
|||||||
assert.ok(true, 'Cosmopolite.shutdown() succeeds');
|
assert.ok(true, 'Cosmopolite.shutdown() succeeds');
|
||||||
|
|
||||||
QUnit.start();
|
QUnit.start();
|
||||||
});
|
}, 10 * 1000);
|
||||||
assert.ok(true, 'new Hogfather()) succeeds');
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user