network chunk v20
This commit is contained in:
@@ -29,7 +29,7 @@ export class UdpClient {
|
||||
}
|
||||
|
||||
// Send heartbeat and get clients that respond with ALIVE, excluding the host machine's IP addresses
|
||||
async getAliveClients(): Promise<string[]> {
|
||||
async getTargetClients(heartbeatCode: string): Promise<string[]> {
|
||||
const subnet = this.getSubnet();
|
||||
const ipRange = this.getIPRange(subnet);
|
||||
|
||||
@@ -45,7 +45,7 @@ export class UdpClient {
|
||||
const aliveClients: string[] = [];
|
||||
for (const ip of activeIps) {
|
||||
if (!localIPs.includes(ip)) {
|
||||
const result = await this.sendHeartbeat(ip);
|
||||
const result = await this.sendHeartbeat(ip, heartbeatCode);
|
||||
if (result.found) {
|
||||
aliveClients.push(ip);
|
||||
}
|
||||
@@ -73,9 +73,8 @@ export class UdpClient {
|
||||
}
|
||||
|
||||
// Send heartbeat to an IP
|
||||
private async sendHeartbeat(ip: string): Promise<{ found: boolean }> {
|
||||
private async sendHeartbeat(ip: string, heartbeatCode: string): Promise<{ found: boolean }> {
|
||||
return new Promise((resolve) => {
|
||||
const heartbeatCode = operationCodes.HEARTBEAT;
|
||||
const heartbeatMessage = MessageHandler.formatMessage(heartbeatCode);
|
||||
|
||||
this.log(`Sending heartbeat to ${ip}`);
|
||||
|
||||
Reference in New Issue
Block a user