@Override public SocketAddress localAddress() { InetSocketAddress addr = channel.localAddress(); return new SocketAddressImpl(addr); }
@Override public SocketAddress localAddress() { InetSocketAddress addr = channel.localAddress(); return new SocketAddressImpl(addr); }
@Override public InetSocketAddress address() { Channel c = channel(); if (c instanceof SocketChannel) { return ((SocketChannel) c).remoteAddress(); } if (c instanceof DatagramChannel) { InetSocketAddress a = ((DatagramChannel) c).remoteAddress(); return a != null ? a : ((DatagramChannel)c ).localAddress(); } throw new IllegalStateException("Does not have an InetSocketAddress"); }
/** * Return local server selector channel address. * * @return local {@link InetSocketAddress} */ default InetSocketAddress address(){ Channel c = channel(); if (c instanceof SocketChannel) { return ((SocketChannel) c).remoteAddress(); } if (c instanceof ServerSocketChannel) { return ((ServerSocketChannel) c).localAddress(); } if (c instanceof DatagramChannel) { InetSocketAddress a = ((DatagramChannel) c).remoteAddress(); return a != null ? a : ((DatagramChannel)c ).localAddress(); } throw new IllegalStateException("Does not have an InetSocketAddress"); }
/** * Return local server selector channel address. * * @return local {@link InetSocketAddress} */ default InetSocketAddress address(){ Channel c = channel(); if (c instanceof SocketChannel) { return ((SocketChannel) c).remoteAddress(); } if (c instanceof ServerSocketChannel) { return ((ServerSocketChannel) c).localAddress(); } if (c instanceof DatagramChannel) { InetSocketAddress a = ((DatagramChannel) c).remoteAddress(); return a != null ? a : ((DatagramChannel)c ).localAddress(); } throw new IllegalStateException("Does not have an InetSocketAddress"); }
/** * Return remote address if remote channel {@link NettyContext} otherwise local * address if server selector channel. * * @return remote or local {@link InetSocketAddress} */ default InetSocketAddress address(){ Channel c = channel(); if (c instanceof SocketChannel) { return ((SocketChannel) c).remoteAddress(); } if (c instanceof ServerSocketChannel) { return ((ServerSocketChannel) c).localAddress(); } if (c instanceof DatagramChannel) { InetSocketAddress a = ((DatagramChannel) c).remoteAddress(); return a != null ? a : ((DatagramChannel)c ).localAddress(); } throw new IllegalStateException("Does not have an InetSocketAddress"); }
/** * Join a multicast group. * * @param multicastAddress multicast address of the group to join * * @return a {@link Publisher} that will be complete when the group has been joined */ @Override public Mono<Void> join(final InetAddress multicastAddress, NetworkInterface iface) { if (null == iface && null != datagramChannel.config().getNetworkInterface()) { iface = datagramChannel.config().getNetworkInterface(); } final ChannelFuture future; if (null != iface) { future = datagramChannel.joinGroup(new InetSocketAddress(multicastAddress, datagramChannel.localAddress() .getPort()), iface); } else { future = datagramChannel.joinGroup(multicastAddress); } return FutureMono.from(future) .doOnSuccess(v -> log.info(format(future.channel(), "JOIN {}"), multicastAddress)); }
/** * Join a multicast group. * * @param multicastAddress multicast address of the group to join * * @return a {@link Publisher} that will be complete when the group has been joined */ @Override public Mono<Void> join(final InetAddress multicastAddress, NetworkInterface iface) { if (null == iface && null != datagramChannel.config().getNetworkInterface()) { iface = datagramChannel.config().getNetworkInterface(); } final ChannelFuture future; if (null != iface) { future = datagramChannel.joinGroup(new InetSocketAddress(multicastAddress, datagramChannel.localAddress() .getPort()), iface); } else { future = datagramChannel.joinGroup(multicastAddress); } return FutureMono.from(future) .doOnSuccess(v -> log.info(format(future.channel(), "JOIN {}"), multicastAddress)); }
/** * Leave a multicast group. * * @param multicastAddress multicast address of the group to leave * * @return a {@link Publisher} that will be complete when the group has been left */ @Override public Mono<Void> leave(final InetAddress multicastAddress, NetworkInterface iface) { if (null == iface && null != datagramChannel.config().getNetworkInterface()) { iface = datagramChannel.config().getNetworkInterface(); } final ChannelFuture future; if (null != iface) { future = datagramChannel.leaveGroup(new InetSocketAddress(multicastAddress, datagramChannel.localAddress() .getPort()), iface); } else { future = datagramChannel.leaveGroup(multicastAddress); } return FutureMono.from(future) .doOnSuccess(v -> log.info(format(future.channel(), "JOIN {}"), multicastAddress)); }
/** * Leave a multicast group. * * @param multicastAddress multicast address of the group to leave * * @return a {@link Publisher} that will be complete when the group has been left */ @Override public Mono<Void> leave(final InetAddress multicastAddress, NetworkInterface iface) { if (null == iface && null != datagramChannel.config().getNetworkInterface()) { iface = datagramChannel.config().getNetworkInterface(); } final ChannelFuture future; if (null != iface) { future = datagramChannel.leaveGroup(new InetSocketAddress(multicastAddress, datagramChannel.localAddress() .getPort()), iface); } else { future = datagramChannel.leaveGroup(multicastAddress); } return FutureMono.from(future) .doOnSuccess(v -> log.info(format(future.channel(), "JOIN {}"), multicastAddress)); }
/** * Join a multicast group. * * @param multicastAddress multicast address of the group to join * * @return a {@link Publisher} that will be complete when the group has been joined */ @Override public Mono<Void> join(final InetAddress multicastAddress, NetworkInterface iface) { if (null == iface && null != datagramChannel.config().getNetworkInterface()) { iface = datagramChannel.config().getNetworkInterface(); } final ChannelFuture future; if (null != iface) { future = datagramChannel.joinGroup(new InetSocketAddress(multicastAddress, datagramChannel.localAddress() .getPort()), iface); } else { future = datagramChannel.joinGroup(multicastAddress); } return FutureMono.from(future) .doOnSuccess(v -> log.info("JOIN {}", multicastAddress)); }
/** * Leave a multicast group. * * @param multicastAddress multicast address of the group to leave * * @return a {@link Publisher} that will be complete when the group has been left */ @Override public Mono<Void> leave(final InetAddress multicastAddress, NetworkInterface iface) { if (null == iface && null != datagramChannel.config().getNetworkInterface()) { iface = datagramChannel.config().getNetworkInterface(); } final ChannelFuture future; if (null != iface) { future = datagramChannel.leaveGroup(new InetSocketAddress(multicastAddress, datagramChannel.localAddress() .getPort()), iface); } else { future = datagramChannel.leaveGroup(multicastAddress); } return FutureMono.from(future) .doOnSuccess(v -> log.info("JOIN {}", multicastAddress)); }