# 1.0.34
- Fixes: - dispatchers.ConnectivityManager.ConnectivityManager: fixing isMaster- Fixed - Modified: - types.nope.ConnectivityManager.interface: - INopeStatusInfo.upTime =renamed=> connectedSince - INopeConnectivityManager added => "upTime" and "connectedSince" - dispatchers.ConnectivityManager.ConnectivityManager: - INopeConnectivityManager added "connectedSince" (which is expressed in the adapted Timestamp.) - Added: - dispatchers.ConnectivityManager.ConnectivityManager.spec: Added Master - Test
This commit is contained in:
parent
4791914998
commit
f4d0460ec2
12
CHANGELOG.md
12
CHANGELOG.md
@ -54,3 +54,15 @@ Inital commit, which is working with the browser
|
|||||||
- dispatcher.getDispatcher: changed option "constructorClass" to "dispatcherConstructorClass"
|
- dispatcher.getDispatcher: changed option "constructorClass" to "dispatcherConstructorClass"
|
||||||
- helpers.limit.spec: Adapted Timings
|
- helpers.limit.spec: Adapted Timings
|
||||||
- loader.getPackageLoader.nodejs/browser: Changed the options.
|
- loader.getPackageLoader.nodejs/browser: Changed the options.
|
||||||
|
|
||||||
|
# 1.0.34
|
||||||
|
- Fixes:
|
||||||
|
- dispatchers.ConnectivityManager.ConnectivityManager: fixing isMaster- Fixed
|
||||||
|
- Modified:
|
||||||
|
- types.nope.ConnectivityManager.interface:
|
||||||
|
- INopeStatusInfo.upTime =renamed=> connectedSince
|
||||||
|
- INopeConnectivityManager added => "upTime" and "connectedSince"
|
||||||
|
- dispatchers.ConnectivityManager.ConnectivityManager:
|
||||||
|
- INopeConnectivityManager added "connectedSince" (which is expressed in the adapted Timestamp.)
|
||||||
|
- Added:
|
||||||
|
- dispatchers.ConnectivityManager.ConnectivityManager.spec: Added Master - Test
|
@ -1 +1 @@
|
|||||||
1.0.33
|
1.0.34
|
@ -6,7 +6,7 @@
|
|||||||
* @desc [description]
|
* @desc [description]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { expect } from "chai";
|
import { assert, expect } from "chai";
|
||||||
import { beforeEach, describe, it } from "mocha";
|
import { beforeEach, describe, it } from "mocha";
|
||||||
import "reflect-metadata";
|
import "reflect-metadata";
|
||||||
import { getLayer } from "../../communication/getLayer.nodejs";
|
import { getLayer } from "../../communication/getLayer.nodejs";
|
||||||
@ -85,7 +85,7 @@ describe("NopeConnectivityManager", function () {
|
|||||||
logger: false,
|
logger: false,
|
||||||
},
|
},
|
||||||
() => new NopeObservable(),
|
() => new NopeObservable(),
|
||||||
"test"
|
"first"
|
||||||
);
|
);
|
||||||
|
|
||||||
first.ready.waitFor().then(() => done());
|
first.ready.waitFor().then(() => done());
|
||||||
@ -197,6 +197,42 @@ describe("NopeConnectivityManager", function () {
|
|||||||
first.dispose(true);
|
first.dispose(true);
|
||||||
|
|
||||||
expect(end - adapted).to.be.equal(0, "There should not be an delta.");
|
expect(end - adapted).to.be.equal(0, "There should not be an delta.");
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it("master", async () => {
|
||||||
|
// Wait for the Handshake
|
||||||
|
await sleep(10);
|
||||||
|
|
||||||
|
assert(first.isMaster, "First should be master");
|
||||||
|
|
||||||
|
// Create the second Element.
|
||||||
|
const second = new NopeConnectivityManager(
|
||||||
|
{
|
||||||
|
communicator,
|
||||||
|
logger: false,
|
||||||
|
},
|
||||||
|
() => new NopeObservable(),
|
||||||
|
"second"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Wait for the Handshake
|
||||||
|
await sleep(10);
|
||||||
|
|
||||||
|
assert(first.isMaster, "First should be master");
|
||||||
|
assert(second.isMaster == false, "Second should not be master");
|
||||||
|
assert(
|
||||||
|
first.master.id == first.id,
|
||||||
|
"First should recognize the first as master"
|
||||||
|
);
|
||||||
|
assert(
|
||||||
|
second.master.id == first.id,
|
||||||
|
"Second should recognize the first as master"
|
||||||
|
);
|
||||||
|
|
||||||
|
first.dispose(true);
|
||||||
|
second.dispose(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,7 @@ import {
|
|||||||
INopeINopeConnectivityOptions,
|
INopeINopeConnectivityOptions,
|
||||||
INopeINopeConnectivityTimeOptions,
|
INopeINopeConnectivityTimeOptions,
|
||||||
INopeObservable,
|
INopeObservable,
|
||||||
INopeStatusInfo,
|
INopeStatusInfo
|
||||||
} from "../../types/nope";
|
} from "../../types/nope";
|
||||||
|
|
||||||
// Chached Moduls, which will be loaded in nodejs
|
// Chached Moduls, which will be loaded in nodejs
|
||||||
@ -146,7 +146,7 @@ export class NopeConnectivityManager implements INopeConnectivityManager {
|
|||||||
},
|
},
|
||||||
pid: process.pid,
|
pid: process.pid,
|
||||||
timestamp: this.now,
|
timestamp: this.now,
|
||||||
upTime: this.upTime,
|
connectedSince: this.connectedSince,
|
||||||
status: ENopeDispatcherStatus.HEALTHY,
|
status: ENopeDispatcherStatus.HEALTHY,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ export class NopeConnectivityManager implements INopeConnectivityManager {
|
|||||||
id: this.id,
|
id: this.id,
|
||||||
pid: this.id,
|
pid: this.id,
|
||||||
timestamp: this.now,
|
timestamp: this.now,
|
||||||
upTime: this.upTime,
|
connectedSince: this.connectedSince,
|
||||||
status: ENopeDispatcherStatus.HEALTHY,
|
status: ENopeDispatcherStatus.HEALTHY,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -245,6 +245,18 @@ export class NopeConnectivityManager implements INopeConnectivityManager {
|
|||||||
return Date.now() - this._connectedSince;
|
return Date.now() - this._connectedSince;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* see {@link INopeConnectivityManager.connectedSince}
|
||||||
|
*
|
||||||
|
* @author M.Karkowski
|
||||||
|
* @readonly
|
||||||
|
* @type {number}
|
||||||
|
* @memberof NopeConnectivityManager
|
||||||
|
*/
|
||||||
|
public get connectedSince(): number {
|
||||||
|
return this._connectedSince + this._deltaTime;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal value to store the Master.
|
* Internal value to store the Master.
|
||||||
*
|
*
|
||||||
@ -276,9 +288,9 @@ export class NopeConnectivityManager implements INopeConnectivityManager {
|
|||||||
*/
|
*/
|
||||||
public get isMaster(): boolean {
|
public get isMaster(): boolean {
|
||||||
if (this.__isMaster === null) {
|
if (this.__isMaster === null) {
|
||||||
const upTime = this.upTime;
|
const connectedSince = this._connectedSince;
|
||||||
for (const info of this.dispatchers.originalData.values()) {
|
for (const info of this.dispatchers.originalData.values()) {
|
||||||
if (info.upTime >= upTime) {
|
if (info.id !== this.id && info.connectedSince < connectedSince) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -363,6 +375,9 @@ export class NopeConnectivityManager implements INopeConnectivityManager {
|
|||||||
'Remote Dispatcher "' + dispatcherId + '" went online'
|
'Remote Dispatcher "' + dispatcherId + '" went online'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Say Hello by sending the Status
|
||||||
|
_this._sendStatus()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ export interface INopeStatusInfo {
|
|||||||
* @type {number}
|
* @type {number}
|
||||||
* @memberof INopeStatusInfo
|
* @memberof INopeStatusInfo
|
||||||
*/
|
*/
|
||||||
upTime: number;
|
connectedSince: number;
|
||||||
/**
|
/**
|
||||||
* The Status of the Dispatcher
|
* The Status of the Dispatcher
|
||||||
*
|
*
|
||||||
@ -255,6 +255,13 @@ export interface INopeConnectivityManager {
|
|||||||
*/
|
*/
|
||||||
readonly id: string;
|
readonly id: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current info of this connectivity-manager.
|
||||||
|
*
|
||||||
|
* @author M.Karkowski
|
||||||
|
* @type {INopeStatusInfo}
|
||||||
|
* @memberof INopeConnectivityManager
|
||||||
|
*/
|
||||||
readonly info: INopeStatusInfo;
|
readonly info: INopeStatusInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -342,6 +349,24 @@ export interface INopeConnectivityManager {
|
|||||||
*/
|
*/
|
||||||
readonly now: number;
|
readonly now: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time since the systeme is connected.
|
||||||
|
*
|
||||||
|
* @author M.Karkowski
|
||||||
|
* @type {number}
|
||||||
|
* @memberof INopeConnectivityManager
|
||||||
|
*/
|
||||||
|
readonly upTime: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timestamp of the connection since it has been established.
|
||||||
|
*
|
||||||
|
* @author M.Karkowski
|
||||||
|
* @type {number}
|
||||||
|
* @memberof INopeConnectivityManager
|
||||||
|
*/
|
||||||
|
readonly connectedSince: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Status of the Master.
|
* Returns the Status of the Master.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user