public static void encodeVarLength(DataOutputBlobWriter<NetPayloadSchema> output, int x) { //little endian //high bit is on until the end byte encodedByte = (byte)(x & 0x7F); x = x >> 7; while (x>0) { output.writeByte(0x80 | encodedByte); encodedByte = (byte)(x & 0x7F); x = x >> 7; } output.writeByte(0xFF & encodedByte); }
private static void appendFixedProtoName(DataOutputBlobWriter<NetPayloadSchema> output) { //NOTE: this is hardcoded from 3.1.1 spec and may not be compatible with 3.1 output.writeByte(0); //MSB output.writeByte(4); //LSB output.writeByte('M'); output.writeByte('Q'); output.writeByte('T'); output.writeByte('T'); }
@Override public void writeDecimal(long m, byte e) { writeByte(e); writePackedLong(m); }
@Override public void writeDecimal(long m, byte e) { writeByte(e); writePackedLong(m); }
@Override public void writeDecimal(long m, byte e) { writeByte(e); writePackedLong(m); }
@Override public void writeByte(int v) { checkLimit(this,1); super.writeByte(v); }
@Override public void writeByte(int v) { checkLimit(this,1); super.writeByte(v); }
public void populate(DataOutputBlobWriter<?> writer) { int location = writer.position(); DataOutputBlobWriter.setIntBackData(writer, location, fieldPos); writer.writePackedLong(m); writer.writeByte(e); prev.populate(writer); } };
public void populate(DataOutputBlobWriter<?> writer) { int location = writer.position(); DataOutputBlobWriter.setIntBackData(writer, location, fieldPos); writer.writePackedLong(m); writer.writeByte(e); prev.populate(writer); } };
private void requestPing(long now, long connectionId, Pipe<NetPayloadSchema> server) { Pipe.presumeRoomForWrite(server); int size = Pipe.addMsgIdx(server, NetPayloadSchema.MSG_PLAIN_210); Pipe.addLongValue(connectionId, server); Pipe.addLongValue(now, server); Pipe.addLongValue(0, server); //always use zero for client requests DataOutputBlobWriter<NetPayloadSchema> output = Pipe.openOutputStream(server); output.writeByte(0xC0); output.writeByte(0x00); output.closeLowLevelField(); Pipe.confirmLowLevelWrite(server, size); Pipe.publishWrites(server); //logger.info("wrote block of {}",len2); }
private void buildPublishMessage(DataOutputBlobWriter<NetPayloadSchema> output, int qos, int packetId, int retain, int topicMeta, int topicLength, int payloadMeta, int payloadLength) { final int pubHead = 0x30 | (0x06&(qos<<1)) | 1&retain; //bit 3 dup is zero which is modified later output.writeByte((0xFF&pubHead)); encodeVarLength(output, topicLength + 2 + payloadLength + (packetId>=0 ? 2 : 0)); //const and remaining length, 2 bytes //variable header output.writeShort(topicLength); Pipe.readBytes(input, output, topicMeta, topicLength); if (packetId>=0) { output.writeShort(packetId); } Pipe.readBytes(input, output, payloadMeta, payloadLength); }
target.writeByte(position);
/** * Writes byte to specified field in pipe * @param value to be written * @param fieldId field to be written to */ public void writeByte(int value, long fieldId) { assert(Pipe.structRegistry(channelWriter.backingPipe).fieldType(fieldId) == StructType.Byte); DataOutputBlobWriter.commitBackData(channelWriter, StructRegistry.extractStructId(fieldId)); DataOutputBlobWriter.setIntBackData( channelWriter, channelWriter.position(), StructRegistry.extractFieldPosition(fieldId)); channelWriter.writeByte(value); assert confirmDataDoesNotWriteOverIndex(fieldId) : "Data has written over index data"; }
/** * Writes byte to specified field in pipe * @param value to be written * @param fieldId field to be written to */ public void writeByte(int value, long fieldId) { assert(Pipe.structRegistry(channelWriter.backingPipe).fieldType(fieldId) == StructType.Byte); DataOutputBlobWriter.commitBackData(channelWriter, StructRegistry.extractStructId(fieldId)); DataOutputBlobWriter.setIntBackData( channelWriter, channelWriter.position(), StructRegistry.extractFieldPosition(fieldId)); channelWriter.writeByte(value); assert confirmDataDoesNotWriteOverIndex(fieldId) : "Data has written over index data"; }
/** * Writes byte to specified field in pipe * @param value to be written * @param fieldId field to be written to */ public void writeByte(int value, long fieldId) { assert(Pipe.structRegistry(channelWriter.backingPipe).fieldType(fieldId) == StructType.Byte); DataOutputBlobWriter.commitBackData(channelWriter, StructRegistry.extractStructId(fieldId)); DataOutputBlobWriter.setIntBackData( channelWriter, channelWriter.position(), StructRegistry.extractFieldPosition(fieldId)); channelWriter.writeByte(value); assert confirmDataDoesNotWriteOverIndex(fieldId) : "Data has written over index data"; }
stream.writeByte(backing[mask & ((maskPosition+i) & 0x3)] ^ backing[mask & pos++] );