Skip to content

Commit 2232215

Browse files
authored
PushConnection close method (#1995)
Exposes a close method in the event that action needs to be triggered from a different channelHandlerContext that has the instance of the pushConnection
1 parent 49fad6d commit 2232215

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

zuul-core/src/main/java/com/netflix/zuul/netty/server/push/PushConnection.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
import io.netty.buffer.ByteBuf;
2222
import io.netty.buffer.Unpooled;
2323
import io.netty.channel.ChannelFuture;
24+
import io.netty.channel.ChannelFutureListener;
2425
import io.netty.channel.ChannelHandlerContext;
26+
import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame;
27+
import io.netty.handler.codec.http.websocketx.WebSocketCloseStatus;
2528

2629
/**
2730
* Author: Susheel Aroskar
@@ -92,4 +95,9 @@ public ChannelFuture sendPushMessage(String mesg) {
9295
public ChannelFuture sendPing() {
9396
return pushProtocol.sendPing(ctx);
9497
}
98+
99+
public void closeConnection(WebSocketCloseStatus status, String message) {
100+
ctx.writeAndFlush(new CloseWebSocketFrame(status, message))
101+
.addListener(ChannelFutureListener.CLOSE);
102+
}
95103
}

0 commit comments

Comments
 (0)