Example usage for io.netty.channel.group ChannelGroupFuture addListeners

List of usage examples for io.netty.channel.group ChannelGroupFuture addListeners

Introduction

In this page you can find the example usage for io.netty.channel.group ChannelGroupFuture addListeners.

Prototype

@Override
    ChannelGroupFuture addListeners(GenericFutureListener<? extends Future<? super Void>>... listeners);

Source Link

Usage

From source file:com.github.mrstampy.gameboot.netty.NettyConnectionRegistry.java

License:Open Source License

/**
 * Send the message to a specific group.
 *
 * @param groupName// ww w.ja  v  a 2  s.co m
 *          the group key
 * @param message
 *          the message
 * @param listeners
 *          the listeners
 */
public void sendToGroup(String groupName, String message, ChannelFutureListener... listeners) {
    groupCheck(groupName);
    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);
    cf.addListeners(all);
}

From source file:com.github.mrstampy.gameboot.netty.NettyConnectionRegistry.java

License:Open Source License

/**
 * Send the message to a specific group.
 *
 * @param groupName/*from   ww  w .ja v a2s . c o m*/
 *          the group key
 * @param message
 *          the message
 * @param listeners
 *          the listeners
 */
public void sendToGroup(String groupName, byte[] message, ChannelFutureListener... listeners) {
    groupCheck(groupName);
    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);
    cf.addListeners(all);
}

From source file:com.github.mrstampy.gameboot.netty.NettyConnectionRegistry.java

License:Open Source License

/**
 * Send to group./*  w  ww.  j a va2  s. co  m*/
 *
 * @param groupName
 *          the group key
 * @param message
 *          the message
 * @param matcher
 *          the matcher
 * @param listeners
 *          the listeners
 */
public void sendToGroup(String groupName, String message, ChannelMatcher matcher,
        ChannelFutureListener... listeners) {
    groupCheck(groupName);
    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);
}

From source file:com.github.mrstampy.gameboot.netty.NettyConnectionRegistry.java

License:Open Source License

/**
 * Send to group.//  ww  w . ja  v  a2s  .  co m
 *
 * @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);
}