All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lorne.sds.server.utils.SocketUtils Maven / Gradle / Ivy

package com.lorne.sds.server.utils;


import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;

/**
 * Created by lorne on 2016/3/7.
 */
public class SocketUtils {


    public static void send(final String uniqueKey, final byte[] data) {
        Channel ctx =  SocketManager.getInstance().getChannelByUniqueKey(uniqueKey);
        send(ctx,data);
    }

    public static void send(final Channel ctx, final byte[] data) {
        if (ctx == null)
            return;
        final ByteBuf byteBufMsg = ctx.alloc().buffer(data.length);
        byteBufMsg.writeBytes(data);
        ctx.writeAndFlush(byteBufMsg);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy