Skip to content

Instantly share code, notes, and snippets.

@zeroFruit
Created July 23, 2022 00:38
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/e239f19345189d95b0d257718c73e057 to your computer and use it in GitHub Desktop.
Save zeroFruit/e239f19345189d95b0d257718c73e057 to your computer and use it in GitHub Desktop.
Channel concept & implementation— el Project (2)
public class LocalChannel extends AbstractChannel {
...
protected void doConnect(LocalServerChannel server, ChannelPromise result) {
this.server = server;
server.connectFrom(this);
state = State.CONNECTED;
remoteAddress = this.server.localAddress();
result.setSuccess(null);
}
...
private class LocalInternal extends AbstractInternal {
@Override
public void connect(SocketAddress remoteAddress, ChannelPromise promise) {
...
Channel boundChannel = LocalChannelRegistry.get(remoteAddress);
if (!(boundChannel instanceof LocalServerChannel)) {
Exception cause = new ConnectException("Connection refused: " + remoteAddress);
promise.setFailure(cause);
return;
}
doConnect((LocalServerChannel) boundChannel, promise);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment