List of usage examples for io.netty.buffer ByteBuf writeLong
public abstract ByteBuf writeLong(long value);
From source file:com.crowsofwar.gorecore.util.GoreCoreByteBufUtil.java
License:Open Source License
public static void writeUUID(ByteBuf buf, UUID uuid) { buf.writeLong(uuid.getMostSignificantBits()); buf.writeLong(uuid.getLeastSignificantBits()); }
From source file:com.ctrip.xpipe.redis.console.health.netty.EchoClient.java
License:Apache License
public static void main(String[] args) throws Exception { // Configure SSL.git final SslContext sslCtx; if (SSL) {/*from w ww . ja v a2 s . c o m*/ sslCtx = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build(); } else { sslCtx = null; } // Configure the client. EventLoopGroup group = new NioEventLoopGroup(); try { Bootstrap b = new Bootstrap(); b.group(group).channel(NioSocketChannel.class).option(ChannelOption.TCP_NODELAY, true) .handler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { ChannelPipeline p = ch.pipeline(); if (sslCtx != null) { p.addLast(sslCtx.newHandler(ch.alloc(), HOST, PORT)); } // p.addLast(new LoggingHandler(LogLevel.INFO)); p.addLast(new EchoClientHandler()); } }); // Start the client. ChannelFuture f = b.connect(HOST, PORT); Channel c = f.channel(); while (true) { ByteBuf buf = Unpooled.buffer(8); buf.writeLong(System.nanoTime()); c.writeAndFlush(buf); Thread.sleep(1000); } } finally { // Shut down the event loop to terminate all threads. group.shutdownGracefully(); } }
From source file:com.datastax.driver.core.CBUtil.java
License:Apache License
public static void writeUUID(UUID uuid, ByteBuf cb) { cb.writeLong(uuid.getMostSignificantBits()); cb.writeLong(uuid.getLeastSignificantBits()); }
From source file:com.Da_Technomancer.crossroads.API.packets.Message.java
License:Creative Commons License
private static void writeLong(long l, ByteBuf buf) { buf.writeLong(l); }
From source file:com.Da_Technomancer.crossroads.API.packets.Message.java
License:Creative Commons License
private static void writeBlockPos(BlockPos pos, ByteBuf buf) { buf.writeLong(pos.toLong()); }
From source file:com.eightkdata.mongowp.mongoserver.encoder.ReplyMessageEncoder.java
License:Open Source License
public static void encodeMessageBody(ByteBuf buffer, ReplyMessage message) { buffer.writeInt(EnumInt32FlagsUtil.getInt32Flags(message.getFlags())); buffer.writeLong(message.getCursorId()); buffer.writeInt(message.getStartingFrom()); buffer.writeInt(message.getDocuments().size()); for (BSONDocument document : message.getDocuments()) { document.writeToByteBuf(buffer); }//from w w w .jav a2 s .c om }
From source file:com.eightkdata.mongowp.server.encoder.ReplyMessageEncoder.java
License:Open Source License
public void encodeMessageBody(ByteBuf buffer, ReplyMessage message) { FluentIterable<? extends BsonDocument> docs = message.getDocuments().getIterable(AllocationType.HEAP); buffer.writeInt(EnumInt32FlagsUtil.getInt32Flags(extractFlags(message))); buffer.writeLong(message.getCursorId()); buffer.writeInt(message.getStartingFrom()); buffer.writeInt(docs.size());/* w w w . j av a2s .co m*/ for (BsonDocument document : docs) { writer.writeInto(buffer, document); } }
From source file:com.example.pojo.server.ServerTimeEncoder.java
License:Apache License
@Override protected void encode(final ChannelHandlerContext ctx, final ServerTime msg, final ByteBuf out) { log.info("encoding: {}", msg); out.writeLong(msg.getValue()); }
From source file:com.example.time.server.TimeServerHandler.java
License:Apache License
@Override public void channelActive(final ChannelHandlerContext ctx) { final OffsetDateTime now = OffsetDateTime.now(zoneId); final long epochSecond = now.toEpochSecond(); log.info("channel active: {}", now); final ByteBuf byteBuf = ctx.alloc().buffer(8); byteBuf.writeLong(epochSecond); Futures.toMono(ctx.writeAndFlush(byteBuf)).subscribe(v -> ctx.close()); }
From source file:com.flowpowered.engine.util.FlowByteBufUtils.java
License:MIT License
public static void writeUUID(ByteBuf buffer, UUID uuid) { buffer.writeLong(uuid.getLeastSignificantBits()); buffer.writeLong(uuid.getMostSignificantBits()); }