foxcord/Foxcord/Gateway/DiscordGatewayClient.Events.cs
2024-09-03 00:07:12 +02:00

17 lines
No EOL
613 B
C#

namespace Foxcord.Gateway;
public partial class DiscordGatewayClient
{
private void HandleHeartbeatAck()
{
_lastHeartbeatAck = DateTimeOffset.UtcNow;
_logger.Verbose("Received heartbeat ACK after {Latency}", _lastHeartbeatAck - _lastHeartbeatSend);
}
private async Task HandleHeartbeatRequest(CancellationToken ct = default)
{
_logger.Information("Early heartbeat requested, sending heartbeat");
await WritePacket(new GatewayPacket { Opcode = GatewayOpcode.Heartbeat, Payload = _lastSequence }, ct);
_lastHeartbeatSend = DateTimeOffset.UtcNow;
}
}