List of usage examples for io.netty.buffer ByteBuf writeByte
public abstract ByteBuf writeByte(int value);
From source file:com.vethrfolnir.network.WritePacket.java
License:Open Source License
public void writeArray(ByteBuf buff, int... vals) { for (int i = 0; i < vals.length; i++) { buff.writeByte(vals[i]); }//from ww w.j a va 2 s . c o m }
From source file:com.vethrfolnir.network.WritePacket.java
License:Open Source License
public void writeArray(ByteBuf buff, byte... vals) { for (int i = 0; i < vals.length; i++) { buff.writeByte(vals[i]); }//from w w w .j a v a 2s .c om }
From source file:com.vethrfolnir.network.WritePacket.java
License:Open Source License
public void writeArray(ByteBuf buff, int fills, byte... vals) { for (int i = 0; i < vals.length; i++) { buff.writeByte(vals[i]); }// ww w .j av a2 s . c o m for (int i = vals.length; i < fills; i++) buff.writeByte(0x00); }
From source file:com.whizzosoftware.foscam.camera.protocol.Order.java
License:Open Source License
public ByteBuf toByteBuf() { ByteBuf b = Unpooled.buffer(23 + text.length); // add "camera operate protocol" b.writeByte('M'); b.writeByte('O'); b.writeByte('_'); b.writeByte('I'); // add "operation code" b.writeByte(operationCode);/* w ww . ja v a 2 s . c o m*/ b.writeByte(0); // add reserve (INT8) b.writeByte(0); // add reserve (BINARY_STREAM[8]) for (int i = 7; i <= 14; i++) { b.writeByte(0); } // add text length b.writeByte((byte) (text.length & 0xFF)); b.writeByte((byte) ((text.length >> 8) & 0xFF)); b.writeByte((byte) ((text.length >> 16) & 0xFF)); b.writeByte((byte) ((text.length >> 24) & 0xFF)); // add reserve (INT32) for (int i = 19; i <= 22; i++) { b.writeByte(0); } b.writeBytes(text); return b; }
From source file:com.whizzosoftware.hobson.davisvantage.api.codec.VantageSerialFrameEncoder.java
License:Open Source License
@Override protected void encode(ChannelHandlerContext ctx, VantageSerialCommand cmd, ByteBuf out) throws Exception { byte[] b = null; switch (cmd.getType()) { case VersionRequest.TYPE: case Test.TYPE: case LoopRequest.TYPE: case LPSRequest.TYPE: b = cmd.getBytes();// w w w.j a v a2s .com break; default: logger.error("Attempt to send invalid command: {}", cmd); } if (b != null) { logger.trace("encode: {}", new String(b)); out.writeBytes(b); out.writeByte('\n'); } else { logger.error("Attempt to send unknown command class: {}", cmd); } }
From source file:com.whizzosoftware.hobson.lifx.api.codec.LIFXFrameEncoder.java
License:Open Source License
protected void writeLightSetColor(ByteBuf buf, LightSetColor m) { writeMessageHeader(buf, m.getHeader()); buf.writeByte(0); // reserved writeColor(buf, m.getColor());//from w w w. j a v a2 s . c o m writeIntLE(buf, m.getDuration()); }
From source file:com.whizzosoftware.hobson.lifx.api.codec.LIFXFrameEncoder.java
License:Open Source License
protected void writeMessageHeader(ByteBuf buf, MessageHeader m) { // write message length writeShortLE(buf, m.getMessageLength()); // write origin/tagged/addressable/protocol buf.writeByte((byte) (m.getProtocol() & 255)); buf.writeByte((byte) ((m.isTagged() ? 32 : 0) + (m.isAddressable() ? 16 : 0) + (m.getProtocol() >> 8))); // write source writeIntLE(buf, m.getSource());/*w w w . j a v a 2s . co m*/ // write target writeLongLE(buf, m.getTarget()); // write reserved buf.writeByte(0); buf.writeByte(0); buf.writeByte(0); buf.writeByte(0); buf.writeByte(0); buf.writeByte(0); // write ack_required/res_required buf.writeByte((byte) ((m.isACKRequired() ? 2 : 0) + (m.isResponseRequired() ? 1 : 0))); // write sequence buf.writeByte(m.getSequence()); // write reserved buf.writeByte(0); buf.writeByte(0); buf.writeByte(0); buf.writeByte(0); buf.writeByte(0); buf.writeByte(0); buf.writeByte(0); buf.writeByte(0); // write type writeShortLE(buf, m.getType()); // write reserved buf.writeByte(0); buf.writeByte(0); }
From source file:com.whizzosoftware.hobson.lifx.api.codec.LIFXFrameEncoder.java
License:Open Source License
protected void writeShortLE(ByteBuf buf, short s) { buf.writeByte(s); buf.writeByte(s >> 8); }
From source file:com.whizzosoftware.hobson.lifx.api.codec.LIFXFrameEncoder.java
License:Open Source License
protected void writeIntLE(ByteBuf buf, int i) { buf.writeByte(i); buf.writeByte(i >> 8);/*from www. j a v a 2 s . c om*/ buf.writeByte(i >> 16); buf.writeByte(i >> 24); }
From source file:com.whizzosoftware.hobson.lifx.api.codec.LIFXFrameEncoder.java
License:Open Source License
protected void writeLongLE(ByteBuf buf, long i) { buf.writeByte((byte) i); buf.writeByte((byte) (i >> 8)); buf.writeByte((byte) (i >> 16)); buf.writeByte((byte) (i >> 24)); buf.writeByte((byte) (i >> 32)); buf.writeByte((byte) (i >> 40)); buf.writeByte((byte) (i >> 48)); buf.writeByte((byte) (i >> 56)); }