private void rejoinMulticastGroup(short universe, String listenAddress) { if (multicastKey != null) { multicastKey.drop(); } try { multicastKey = joinMulticastGroup(universe, listenAddress); } catch (IOException e) { e.printStackTrace(); } }
@Override public ChannelFuture leaveGroup( InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source, ChannelPromise promise) { if (PlatformDependent.javaVersion() < 7) { throw new UnsupportedOperationException(); } if (multicastAddress == null) { throw new NullPointerException("multicastAddress"); } if (networkInterface == null) { throw new NullPointerException("networkInterface"); } synchronized (this) { if (memberships != null) { List<MembershipKey> keys = memberships.get(multicastAddress); if (keys != null) { Iterator<MembershipKey> keyIt = keys.iterator(); while (keyIt.hasNext()) { MembershipKey key = keyIt.next(); if (networkInterface.equals(key.networkInterface())) { if (source == null && key.sourceAddress() == null || source != null && source.equals(key.sourceAddress())) { key.drop(); keyIt.remove(); } } } if (keys.isEmpty()) { memberships.remove(multicastAddress); } } } } promise.setSuccess(); return promise; }