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); | |
} | |
... |
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 LocalServerChannel extends AbstractServerChannel { | |
... | |
private class LocalServerInternal extends AbstractInternal { | |
@Override | |
public void doBind(SocketAddress localAddress) { | |
ObjectUtil.checkNotNull(localAddress, "localAddress"); | |
LocalServerChannel.this.localAddress = | |
LocalChannelRegistry.register(LocalServerChannel.this, localAddress); | |
state = State.BOUND; | |
} |
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 LocalChannelTransportTests { | |
private static final String SERVER_ADDRESS = "server:addr"; | |
private DefaultChannelEventLoopGroup group1, group2; | |
@BeforeEach | |
public void setUp() { | |
group1 = new DefaultChannelEventLoopGroup(1); | |
group2 = new DefaultChannelEventLoopGroup(1); | |
} |
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, |
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 AbstractChannelHandlerContext implements ChannelHandlerContext { | |
... | |
@Override | |
public ChannelPromise bind(SocketAddress localAddress, ChannelPromise promise) { | |
ObjectUtil.checkNotNull(localAddress, "localAddress"); | |
if (isNotValidPromise(promise)) { | |
// canceled | |
return promise; | |
} |
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
private static final class HeadContextHandler | |
implements ChannelOutboundHandler, ChannelInboundHandler { | |
@Override | |
public void bind( | |
ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) { | |
ctx.channel().internal().bind(localAddress, promise); | |
} | |
@Override |
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 AbstractChannelHandlerContext implements ChannelHandlerContext { | |
static void invokeExceptionCaught( | |
final AbstractChannelHandlerContext next, final Throwable cause) { | |
EventLoop eventLoop = next.eventLoop(); | |
if (eventLoop.inEventLoop()) { | |
next.invokeExceptionCaught(cause); | |
} else { | |
eventLoop.execute(() -> next.invokeExceptionCaught(cause)); | |
} |
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 AbstractChannelHandlerContext implements ChannelHandlerContext { | |
AbstractChannelHandlerContext( | |
String name, | |
ChannelPipeline pipeline, | |
EventLoop eventLoop, | |
Class<? extends ChannelHandler> handlerClass) { | |
this.name = ObjectUtil.checkNotNull(name, "name"); | |
this.pipeline = pipeline; | |
this.executionFlag = ChannelHandlerFlag.flag(handlerClass); | |
this.eventLoop = eventLoop; |
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 interface ChannelOutboundHandler extends ChannelHandler { | |
/** | |
* Called once a bind operation is made. | |
*/ | |
void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) | |
throws Exception; | |
/** | |
* Called once a connect operation is made. | |
*/ |
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
/** | |
* {@link ChannelHandler} which adds callbacks for state changes. This allows the user to hook in to | |
* state changes easily. | |
*/ | |
public interface ChannelInboundHandler extends ChannelHandler { | |
/** | |
* Called when {@link Channel} of the {@link ChannelHandlerContext} was registered with its {@link | |
* ChannelEventLoop} | |
*/ | |
void channelRegistered(ChannelHandlerContext ctx) throws Exception; |
NewerOlder