Skip to content

Commit

Permalink
Adding debug output for current connection state every minute
Browse files Browse the repository at this point in the history
  • Loading branch information
Supereg committed Oct 18, 2020
1 parent 091e2a4 commit 1b47a4c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/lib/util/eventedhttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ export class EventedHTTPServer extends EventEmitter {
constructor() {
super();
this.tcpServer = net.createServer();
const interval = setInterval(() => {
let connectionString = "";
for (const connection of this.connections) {
if (connectionString) {
connectionString += ", ";
} else {
connectionString += connection.remoteAddress + ":" + connection.remotePort;
}
}
debug("Current " + this.connections.size + " hap connections open: " + connectionString);
}, 60000);
interval.unref();
}

public listen(targetPort: number, hostname?: string): void {
Expand Down Expand Up @@ -247,6 +259,7 @@ export class HAPConnection extends EventEmitter {
readonly sessionID: SessionIdentifier; // uuid unique to every HAP connection
private state: HAPConnectionState = HAPConnectionState.CONNECTING;
readonly remoteAddress: string; // cache because it becomes undefined in 'onClientSocketClose'
readonly remotePort: number;
readonly networkInterface: string;

private readonly tcpSocket: Socket;
Expand Down Expand Up @@ -277,6 +290,7 @@ export class HAPConnection extends EventEmitter {
this.server = server;
this.sessionID = uuid.generate(clientSocket.remoteAddress + ':' + clientSocket.remotePort);
this.remoteAddress = clientSocket.remoteAddress!; // cache because it becomes undefined in 'onClientSocketClose'
this.remotePort = clientSocket.remotePort!;
this.networkInterface = HAPConnection.getLocalNetworkInterface(clientSocket);

// clientSocket is the socket connected to the actual iOS device
Expand Down

0 comments on commit 1b47a4c

Please sign in to comment.