Files
AsminVoicechat/source/decompiled/de/maxhenkel/voicechat/debug/PingHandler.java
T
asminme bbccd4a815
Build AsminVoicechat / prepare-release (push) Successful in 14s
Build AsminVoicechat / build-and-test (17) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (18) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (19) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (20) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (21) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (22) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (23) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (24) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (25) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (26) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (27-ea) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (16) (push) Canceled after 38s
first commit
2026-10-24 15:18:03 +02:00

47 lines
1.7 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* io.netty.buffer.Unpooled
*/
package de.maxhenkel.voicechat.debug;
import de.maxhenkel.voicechat.Voicechat;
import de.maxhenkel.voicechat.util.FriendlyByteBuf;
import de.maxhenkel.voicechat.voice.server.Server;
import io.netty.buffer.Unpooled;
import java.net.SocketAddress;
import java.util.UUID;
public class PingHandler {
public static final UUID PING_V1 = UUID.fromString("58bc9ae9-c7a8-45e4-a11c-efbb67199425");
private static final int PAYLOAD_SIZE = 24;
public static boolean onPacket(Server server, SocketAddress socketAddress, UUID playerID, FriendlyByteBuf buf) {
if (!Voicechat.SERVER_CONFIG.allowPings.get().booleanValue()) {
return false;
}
if (!PING_V1.equals(playerID)) {
return false;
}
try {
byte[] payload = buf.readByteArray(24);
FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.wrappedBuffer((byte[])payload));
UUID id = buffer.readUUID();
long timestamp = buffer.readLong();
Voicechat.LOGGER.debug("Received ping {} from {}", id, socketAddress);
FriendlyByteBuf responseBuffer = new FriendlyByteBuf(Unpooled.buffer((int)24));
responseBuffer.writeUUID(id);
responseBuffer.writeLong(timestamp);
byte[] response = new byte[responseBuffer.readableBytes()];
responseBuffer.readBytes(response);
server.getSocket().send(response, socketAddress);
}
catch (Exception e) {
Voicechat.LOGGER.debug("Failed to send ping to {}: {}", socketAddress, e.getMessage());
}
return true;
}
}