SystemQuery, Agent, PeerServer: Add listening property

This commit is contained in:
Starbeamrainbowlabs 2022-02-24 01:27:14 +00:00
parent c3fae244e0
commit c9ac3ea108
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
3 changed files with 11 additions and 0 deletions

View file

@ -28,6 +28,8 @@ class SystemQuery extends EventEmitter {
} }
} }
get listening() { return this.agent !== null ? this.agent.listening : false; }
// TODO: Handle duplicate connections better by both skipping counting them here, and also implementing a more robust reaper for killing duplicate connections that always kills the newest/oldest connection to avoid issues. // TODO: Handle duplicate connections better by both skipping counting them here, and also implementing a more robust reaper for killing duplicate connections that always kills the newest/oldest connection to avoid issues.

View file

@ -19,11 +19,16 @@ class Agent extends EventEmitter {
get connected_peers() { return this.server.connected_peers; } get connected_peers() { return this.server.connected_peers; }
get connecting_peers() { return this.server.connecting_peers; } get connecting_peers() { return this.server.connecting_peers; }
get listening() { return this.server !== null ? this.server.listening : false; }
constructor(config) { constructor(config) {
super(); super();
this.config = config; this.config = config;
this.peer_id = null;
this.peer_name = null;
this.server = null;
} }
async find_secret() { async find_secret() {

View file

@ -21,6 +21,10 @@ import Peer from './Peer.mjs';
* @extends EventEmitter * @extends EventEmitter
*/ */
class PeerServer extends EventEmitter { class PeerServer extends EventEmitter {
get listening() {
return this.server instanceof net.Server ? this.server.listening : false;
}
constructor(our_id, secret_join) { constructor(our_id, secret_join) {
super(); super();