Example usage for io.netty.channel.group ChannelGroup writeAndFlush

List of usage examples for io.netty.channel.group ChannelGroup writeAndFlush

Introduction

In this page you can find the example usage for io.netty.channel.group ChannelGroup writeAndFlush.

Prototype

ChannelGroupFuture writeAndFlush(Object message);

Source Link

Document

Shortcut for calling #write(Object) and #flush() .

Usage

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

License:Open Source License

/**
 * Send the message to a specific group.
 *
 * @param groupName/*from  w  ww  .ja  v a 2s  .  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 w  ww .  j  a  v a  2  s  . c  om*/
 *          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);
}