本文整理了Java中io.netty.bootstrap.Bootstrap.register()
方法的一些代码示例,展示了Bootstrap.register()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bootstrap.register()
方法的具体详情如下:
包路径:io.netty.bootstrap.Bootstrap
类名称:Bootstrap
方法名:register
暂无
代码示例来源:origin: redisson/redisson
ChannelFuture future = b.register();
Throwable cause = future.cause();
if (cause != null) {
代码示例来源:origin: wildfly/wildfly
ch = (DatagramChannel) b.register().channel();
ch.config().setRecvByteBufAllocator(new FixedRecvByteBufAllocator(maxPayloadSize));
代码示例来源:origin: org.restcomm.media/network
/**
* {@inheritDoc}
*
* @throws IllegalStateException If manager is already closed.
*/
@Override
public Channel openChannel() throws IOException, IllegalStateException {
assertOpen();
try {
return this.bootstrap.clone().register().sync().channel();
} catch (Exception e) {
throw new IOException("Could not open channel.", e);
}
}
代码示例来源:origin: org.restcomm.media.core/media-core-network
/**
* {@inheritDoc}
*
* @throws IllegalStateException If manager is already closed.
*/
@Override
public Channel openChannel() throws IOException, IllegalStateException {
assertOpen();
try {
return this.bootstrap.clone().register().sync().channel();
} catch (Exception e) {
throw new IOException("Could not open channel.", e);
}
}
代码示例来源:origin: org.restcomm.media.core/network
/**
* {@inheritDoc}
*
* @throws IllegalStateException If manager is already closed.
*/
@Override
public Channel openChannel() throws IOException, IllegalStateException {
assertOpen();
try {
return this.bootstrap.clone().register().sync().channel();
} catch (Exception e) {
throw new IOException("Could not open channel.", e);
}
}
代码示例来源:origin: org.restcomm.media/network
/**
* {@inheritDoc}
*
* @throws IllegalStateException If manager is already closed.
*/
@Override
public void openChannel(FutureCallback<Channel> callback) throws IllegalStateException {
assertOpen();
ChannelFuture future = this.bootstrap.clone().register();
future.addListener(new NetworkManagerChannelFutureCallback(callback));
}
代码示例来源:origin: org.restcomm.media.core/media-core-network
/**
* {@inheritDoc}
*
* @throws IllegalStateException If manager is already closed.
*/
@Override
public void openChannel(FutureCallback<Channel> callback) throws IllegalStateException {
assertOpen();
ChannelFuture future = this.bootstrap.clone().register();
future.addListener(new NetworkManagerChannelFutureCallback(callback));
}
代码示例来源:origin: org.restcomm.media.core/network
/**
* {@inheritDoc}
*
* @throws IllegalStateException If manager is already closed.
*/
@Override
public void openChannel(FutureCallback<Channel> callback) throws IllegalStateException {
assertOpen();
ChannelFuture future = this.bootstrap.clone().register();
future.addListener(new NetworkManagerChannelFutureCallback(callback));
}
代码示例来源:origin: io.netty/netty-testsuite
public void testMultipleConnect(ServerBootstrap sb, Bootstrap cb) throws Exception {
Channel sc = null;
Channel cc = null;
try {
sb.childHandler(new ChannelInboundHandlerAdapter());
sc = sb.bind(NetUtil.LOCALHOST, 0).syncUninterruptibly().channel();
cb.handler(new ChannelInboundHandlerAdapter());
cc = cb.register().syncUninterruptibly().channel();
cc.connect(sc.localAddress()).syncUninterruptibly();
ChannelFuture connectFuture2 = cc.connect(sc.localAddress()).await();
assertTrue(connectFuture2.cause() instanceof AlreadyConnectedException);
} finally {
if (cc != null) {
cc.close();
}
if (sc != null) {
sc.close();
}
}
}
代码示例来源:origin: io.netty/netty-testsuite
public void testLocalAddressAfterConnect(ServerBootstrap sb, Bootstrap cb) throws Throwable {
Channel serverChannel = null;
Channel clientChannel = null;
try {
final Promise<InetSocketAddress> localAddressPromise = ImmediateEventExecutor.INSTANCE.newPromise();
serverChannel = sb.childHandler(new ChannelInboundHandlerAdapter() {
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
localAddressPromise.setSuccess((InetSocketAddress) ctx.channel().localAddress());
}
}).bind().syncUninterruptibly().channel();
clientChannel = cb.handler(new ChannelInboundHandlerAdapter()).register().syncUninterruptibly().channel();
assertNull(clientChannel.localAddress());
assertNull(clientChannel.remoteAddress());
clientChannel.connect(serverChannel.localAddress()).syncUninterruptibly().channel();
assertLocalAddress((InetSocketAddress) clientChannel.localAddress());
assertNotNull(clientChannel.remoteAddress());
assertLocalAddress(localAddressPromise.get());
} finally {
if (clientChannel != null) {
clientChannel.close().syncUninterruptibly();
}
if (serverChannel != null) {
serverChannel.close().syncUninterruptibly();
}
}
}
代码示例来源:origin: io.netty/netty-testsuite
} else {
cb.option(ChannelOption.DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION, true);
cc = cb.register().sync().channel();
代码示例来源:origin: io.netty/netty-resolver-dns
ChannelFuture future = b.register();
Throwable cause = future.cause();
if (cause != null) {
代码示例来源:origin: org.asynchttpclient/netty-resolver-dns
ch = (DatagramChannel) b.register().channel();
ch.config().setRecvByteBufAllocator(new FixedRecvByteBufAllocator(maxPayloadSize));
代码示例来源:origin: org.jboss.eap/wildfly-client-all
ch = (DatagramChannel) b.register().channel();
ch.config().setRecvByteBufAllocator(new FixedRecvByteBufAllocator(maxPayloadSize));
代码示例来源:origin: apache/activemq-artemis
@Test
public void testConnectionTimeoutConfig() throws Exception {
final int timeout = 23456;
TransportConfiguration transport = new TransportConfiguration(NETTY_CONNECTOR_FACTORY);
transport.getParams().put(TransportConstants.NETTY_CONNECT_TIMEOUT, timeout);
ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(transport);
ClientSessionFactoryImpl factory = (ClientSessionFactoryImpl) locator.createSessionFactory();
NettyConnector connector = (NettyConnector) factory.getConnector();
Bootstrap bootstrap = connector.getBootStrap();
assertEquals(timeout, bootstrap.register().channel().config().getConnectTimeoutMillis());
factory.close();
locator.close();
}
}
内容来源于网络,如有侵权,请联系作者删除!