本文整理汇总了Java中io.netty.channel.group.ChannelMatcher类的典型用法代码示例。如果您正苦于以下问题:Java ChannelMatcher类的具体用法?Java ChannelMatcher怎么用?Java ChannelMatcher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChannelMatcher类属于io.netty.channel.group包,在下文中一共展示了ChannelMatcher类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendToGroup
import io.netty.channel.group.ChannelMatcher; //导入依赖的package包/类
/**
* Send to group.
*
* @param groupName
* the group key
* @param message
* the message
* @param matcher
* the matcher
* @param listeners
* the listeners
*/
public void sendToGroup(String groupName, byte[] message, ChannelMatcher matcher,
ChannelFutureListener... listeners) {
groupCheck(groupName);
checkMessage(message);
if (!groups.containsKey(groupName)) {
log.warn("No group {} to send message {}", groupName, message);
return;
}
ChannelGroup group = groups.get(groupName);
ChannelFutureListener[] all = utils.prependArray(f -> log((ChannelGroupFuture) f, groupName), listeners);
ChannelGroupFuture cf = group.writeAndFlush(message, matcher);
cf.addListeners(all);
}
示例2: createMatcher
import io.netty.channel.group.ChannelMatcher; //导入依赖的package包/类
private ChannelMatcher createMatcher(SystemIdKey... except) {
if (except == null || except.length == 0) return NOOP_MATCHER;
List<Channel> exceptions = new ArrayList<>();
for (SystemIdKey key : except) {
Channel c = get(key);
if (c != null) exceptions.add(c);
}
return exceptions.isEmpty() ? NOOP_MATCHER : new ChannelMatcher() {
@Override
public boolean matches(Channel channel) {
return !exceptions.contains(channel);
}
};
}
示例3: sendToAllExcept
import io.netty.channel.group.ChannelMatcher; //导入依赖的package包/类
@Override
public void sendToAllExcept(final List<Command> commands, final Object nonReciver) {
clients.writeAndFlush(commands, new ChannelMatcher() {
@Override
public boolean matches(final Channel candidate) {
return candidate != nonReciver;
}
});
}
示例4: sendToAll
import io.netty.channel.group.ChannelMatcher; //导入依赖的package包/类
/**
* Send to all.
*
* @param message
* the message
* @param matcher
* the matcher
* @param listeners
* the listeners
*/
public void sendToAll(String message, ChannelMatcher matcher, ChannelFutureListener... listeners) {
sendToGroup(ALL, message, matcher, listeners);
}