Created
July 23, 2022 00:38
-
-
Save zeroFruit/e239f19345189d95b0d257718c73e057 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 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