Skip to content

Commit

Permalink
Break keepalive interval out to protected helper to allow override
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderEllis committed Jun 19, 2024
1 parent 2c62b9f commit 95bd815
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.codec.http.websocketx.PingWebSocketFrame;
import io.netty.util.concurrent.ScheduledFuture;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -179,6 +180,10 @@ public final void userEventTriggered(ChannelHandlerContext ctx, Object evt) thro
super.userEventTriggered(ctx, evt);
}

protected int getKeepAliveInterval() {
return KEEP_ALIVE_INTERVAL.get();
}

/**
* Register authenticated client - represented by PushAuthEvent - with PushConnectionRegistry of this instance.
*
Expand All @@ -202,7 +207,7 @@ protected void registerClient(
if (KEEP_ALIVE_ENABLED.get()) {
scheduledFutures.add(ctx.executor()
.scheduleWithFixedDelay(
this::keepAlive, KEEP_ALIVE_INTERVAL.get(), KEEP_ALIVE_INTERVAL.get(), TimeUnit.SECONDS));
this::keepAlive, getKeepAliveInterval(), getKeepAliveInterval(), TimeUnit.SECONDS));
}
}

Expand Down

0 comments on commit 95bd815

Please sign in to comment.