Java Code Examples for io.netty.channel.ChannelPromise#trySuccess()
The following examples show how to use
io.netty.channel.ChannelPromise#trySuccess() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UkcpClientChannel.java From kcp-netty with MIT License | 6 votes |
private void fulfillConnectPromise(ChannelPromise promise, boolean wasActive) { if (promise == null) { // Closed via cancellation and the promise has been notified already. return; } // Get the state as trySuccess() may trigger an ChannelFutureListener that will close the Channel. // We still need to ensure we call fireChannelActive() in this case. boolean active = isActive(); // trySuccess() will return false if a user cancelled the connection attempt. boolean promiseSet = promise.trySuccess(); // Regardless if the connection attempt was cancelled, channelActive() event should be triggered, // because what happened is what happened. if (!wasActive && active) { pipeline().fireChannelActive(); } // If a user cancelled the connection attempt, close the channel, which is followed by channelInactive(). if (!promiseSet) { close(voidPromise()); } }
Example 2
Source File: AbstractNioChannel.java From netty4.0.27Learn with Apache License 2.0 | 6 votes |
private void fulfillConnectPromise(ChannelPromise promise, boolean wasActive) { if (promise == null) { // Closed via cancellation and the promise has been notified already. return; } // trySuccess() will return false if a user cancelled the connection attempt. boolean promiseSet = promise.trySuccess(); // Regardless if the connection attempt was cancelled, channelActive() event should be triggered, // because what happened is what happened. if (!wasActive && isActive()) { pipeline().fireChannelActive(); } // If a user cancelled the connection attempt, close the channel, which is followed by channelInactive(). if (!promiseSet) { close(voidPromise()); } }
Example 3
Source File: AbstractEpollStreamChannel.java From netty4.0.27Learn with Apache License 2.0 | 6 votes |
private void fulfillConnectPromise(ChannelPromise promise, boolean wasActive) { if (promise == null) { // Closed via cancellation and the promise has been notified already. return; } active = true; // trySuccess() will return false if a user cancelled the connection attempt. boolean promiseSet = promise.trySuccess(); // Regardless if the connection attempt was cancelled, channelActive() event should be triggered, // because what happened is what happened. if (!wasActive && isActive()) { pipeline().fireChannelActive(); } // If a user cancelled the connection attempt, close the channel, which is followed by channelInactive(). if (!promiseSet) { close(voidPromise()); } }
Example 4
Source File: AbstractNioChannel.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
private void fulfillConnectPromise(ChannelPromise promise, boolean wasActive) { if (promise == null) { // Closed via cancellation and the promise has been notified already.关闭通过取消和承诺已经通知。 return; } // Get the state as trySuccess() may trigger an ChannelFutureListener that will close the Channel. // We still need to ensure we call fireChannelActive() in this case.//获取trySuccess()的状态,可能触发一个ChannelFutureListener关闭该通道。 //在这种情况下,我们仍然需要确保调用fireChannelActive()。 // 通道状态 boolean active = isActive(); // trySuccess() will return false if a user cancelled the connection attempt.如果用户取消了连接尝试,trySuccess()将返回false。 boolean promiseSet = promise.trySuccess(); // Regardless if the connection attempt was cancelled, channelActive() event should be triggered, // because what happened is what happened.//不管连接尝试是否被取消,都会触发channelActive()事件, //因为已经发生的就是已经发生的。 if (!wasActive && active) { // 管道触发渠道激活 pipeline().fireChannelActive(); } // If a user cancelled the connection attempt, close the channel, which is followed by channelInactive().如果用户取消了连接尝试,那么关闭通道,后面跟着channelInactive()。 if (!promiseSet) { close(voidPromise()); } }
Example 5
Source File: ZMTPFramingEncoder.java From netty-zmtp with Apache License 2.0 | 5 votes |
@Override public boolean trySuccess() { final boolean result = super.trySuccess(); for (final ChannelPromise promise : promises) { promise.trySuccess(); } return result; }