Java Code Examples for io.netty.buffer.Unpooled#copyLong()

The following examples show how to use io.netty.buffer.Unpooled#copyLong() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Hash.java    From redisson with Apache License 2.0 6 votes vote down vote up
public static String hash128toBase64(ByteBuf objectState) {
    long[] hash = hash128(objectState);

    ByteBuf buf = Unpooled.copyLong(hash[0], hash[1]);
    try {
        ByteBuf b = Base64.encode(buf);
        try {
            String s = b.toString(CharsetUtil.UTF_8);
            return s.substring(0, s.length() - 2);
        } finally {
            b.release();
        }
    } finally {
        buf.release();
    }
}
 
Example 2
Source File: OnConnectController.java    From spring-boot-netty with MIT License 5 votes vote down vote up
@NettyOnConnect(serverName = "server1", priority = 1)
private void onConnect1(final ChannelHandlerContext ctx, final Channel channel) {
    calls.add(ON_CONNECT1);
    counter.arrive();

    final ByteBuf r1 = Unpooled.copyLong(92L);
    final ByteBuf r2 = Unpooled.copyLong(87L);

    ctx.writeAndFlush(r1);
    channel.writeAndFlush(r2);
}
 
Example 3
Source File: OnConnectController.java    From spring-boot-netty with MIT License 5 votes vote down vote up
@SuppressWarnings("WeakerAccess")
@NettyOnConnect(serverName = "server1", priority = 2)
ByteBuf onConnect2(final ChannelHandlerContext ignored) {
    calls.add(ON_CONNECT2);
    counter.arrive();
    return Unpooled.copyLong(106L);
}
 
Example 4
Source File: OnDisconnectController.java    From spring-boot-netty with MIT License 5 votes vote down vote up
@NettyOnDisconnect(serverName = "server1", priority = 1)
private void onDisconnect1(final ChannelFuture future, final Channel channel) {
    calls.add(ON_DISCONNECT1);
    counter.arrive();

    final ByteBuf r1 = Unpooled.copyLong(92L);
    final ByteBuf r2 = Unpooled.copyLong(87L);

    try {
        future.channel().writeAndFlush(r1);
        channel.writeAndFlush(r2);
    } catch (final Exception ignored) {
    }
}
 
Example 5
Source File: OnDisconnectController.java    From spring-boot-netty with MIT License 5 votes vote down vote up
@SuppressWarnings("WeakerAccess")
@NettyOnDisconnect(serverName = "server1", priority = 2)
ByteBuf onDisconnect2() {
    calls.add(ON_DISCONNECT2);
    counter.arrive();
    return Unpooled.copyLong(106L);
}
 
Example 6
Source File: Hash.java    From redisson with Apache License 2.0 5 votes vote down vote up
public static byte[] hash128toArray(ByteBuf objectState) {
    long[] hash = hash128(objectState);

    ByteBuf buf = Unpooled.copyLong(hash[0], hash[1]);
    try {
        byte[] dst = new byte[buf.readableBytes()];
        buf.readBytes(dst);
        return dst;
    } finally {
        buf.release();
    }
}
 
Example 7
Source File: CustomResolversController.java    From spring-boot-netty with MIT License 4 votes vote down vote up
@NettyOnConnect(serverName = "server1")
public ByteBuf onConnect(final long rnd) {
    counter.arrive();
    return Unpooled.copyLong(rnd);
}
 
Example 8
Source File: CustomResolversController.java    From spring-boot-netty with MIT License 4 votes vote down vote up
@NettyOnMessage(serverName = "server1")
public ByteBuf onMessage(final Long rnd) {
    counter.arrive();
    return Unpooled.copyLong(rnd);
}