@Override
public final void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
this.ctx = ctx;
if (! destroyed.get()) {
if (evt == pushProtocol.getHandshakeCompleteEvent()) {
pushConnection = new PushConnection(pushProtocol, ctx);
ctx.executor().schedule(this::closeIfNotAuthenticated, UNAUTHENTICATED_CONN_TTL.get(), TimeUnit.SECONDS);
logger.debug("WebSocket handshake complete.");
}
else if (evt instanceof PushUserAuth) {
authEvent = (PushUserAuth) evt;
if (authEvent.isSuccess()) {
logger.debug("registering client {}", authEvent);
ctx.pipeline().remove(PushAuthHandler.NAME);
registerClient(ctx, authEvent, pushConnection, pushConnectionRegistry);
logger.debug("Authentication complete {}", authEvent);
} else {
sendErrorAndClose(1008, "Auth Failed");
}
}
}
super.userEventTriggered(ctx, evt);
}