Add WebSocketClientHandshaker.close()

- Fixes #1470
This commit is contained in:
Trustin Lee 2013-06-25 18:52:27 +09:00
parent c7c9e743ce
commit cfd514d099
2 changed files with 34 additions and 0 deletions

View File

@ -237,4 +237,35 @@ public abstract class WebSocketClientHandshaker {
*/
protected abstract ChannelOutboundHandler newWebSocketEncoder();
/**
* Performs the closing handshake
*
* @param channel
* Channel
* @param frame
* Closing Frame that was received
*/
public ChannelFuture close(Channel channel, CloseWebSocketFrame frame) {
if (channel == null) {
throw new NullPointerException("channel");
}
return close(channel, frame, channel.newPromise());
}
/**
* Performs the closing handshake
*
* @param channel
* Channel
* @param frame
* Closing Frame that was received
* @param promise
* the {@link ChannelPromise} to be notified when the closing handshake is done
*/
public ChannelFuture close(Channel channel, CloseWebSocketFrame frame, ChannelPromise promise) {
if (channel == null) {
throw new NullPointerException("channel");
}
return channel.write(frame, promise);
}
}

View File

@ -217,6 +217,9 @@ public abstract class WebSocketServerHandshaker {
* the {@link ChannelPromise} to be notified when the closing handshake is done
*/
public ChannelFuture close(Channel channel, CloseWebSocketFrame frame, ChannelPromise promise) {
if (channel == null) {
throw new NullPointerException("channel");
}
return channel.write(frame, promise).addListener(ChannelFutureListener.CLOSE);
}