Created
July 23, 2022 00:35
-
-
Save zeroFruit/de957778d73d58b0e7456326b7c3b543 to your computer and use it in GitHub Desktop.
Channel concept & implementation— el Project (2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class AbstractTransport<T extends AbstractTransport<T, C>, C extends Channel> { | |
public ChannelPromise bind(SocketAddress localAddress) { | |
doBind(...); | |
} | |
private void doBind( | |
final ChannelPromise registered, | |
final Channel channel, | |
final SocketAddress localAddress, | |
final ChannelPromise result) { | |
channel | |
.channelEventLoop() | |
.execute( | |
() -> { | |
channel | |
.bind(localAddress) | |
.addListener( | |
promise -> { | |
if (promise.isSuccess()) { | |
result.setSuccess(null); | |
return; | |
} | |
result.setFailure(promise.cause()); | |
}); | |
return; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment