Skip to content

Instantly share code, notes, and snippets.

@zeroFruit
Created July 23, 2022 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeroFruit/de957778d73d58b0e7456326b7c3b543 to your computer and use it in GitHub Desktop.
Save zeroFruit/de957778d73d58b0e7456326b7c3b543 to your computer and use it in GitHub Desktop.
Channel concept & implementation— el Project (2)
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