diff options
Diffstat (limited to 'pkg/discord/gateway/heartbeat.go')
| -rw-r--r-- | pkg/discord/gateway/heartbeat.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/pkg/discord/gateway/heartbeat.go b/pkg/discord/gateway/heartbeat.go index 6cefb21..a8f793d 100644 --- a/pkg/discord/gateway/heartbeat.go +++ b/pkg/discord/gateway/heartbeat.go @@ -9,7 +9,7 @@ import ( ) type Heartbeat interface { - Start(ctx context.Context, interval uint64) + Start(ctx context.Context, interval time.Duration) ForceHeartbeat() Ack() @@ -31,7 +31,7 @@ func NewHeartbeat(logger *zerolog.Logger, gateway Gateway) *HeartbeatImpl { } } -func (h *HeartbeatImpl) Start(ctx context.Context, interval uint64) { +func (h *HeartbeatImpl) Start(ctx context.Context, interval time.Duration) { h.ctx = ctx go h.heartbeatRoutine(interval) } @@ -45,14 +45,14 @@ func (h *HeartbeatImpl) Ack() { h.logger.Debug().Msg("received heartbeat ack") } -func (h *HeartbeatImpl) heartbeatRoutine(interval uint64) { - h.logger.Debug().Msgf("beating heart every %dms", interval) +func (h *HeartbeatImpl) heartbeatRoutine(interval time.Duration) { + h.logger.Debug().Msgf("beating heart every %dms", interval.Milliseconds()) // REF: heartbeat_interval * jitter jitter := rand.Intn(int(interval)) - time.Sleep(time.Duration(jitter) * time.Millisecond) + time.Sleep(time.Duration(jitter)) - ticker := time.NewTicker(time.Duration(interval) * time.Millisecond) + ticker := time.NewTicker(interval) defer ticker.Stop() for { |
