List of usage examples for com.google.common.io ByteArrayDataOutput writeByte
@Override void writeByte(int v);
From source file:de.paleocrafter.pmfw.network.packet.PaleoPacket.java
public final Packet makePacket() throws IllegalArgumentException { if (PaleoPacketHandler.CHANNEL_NAME != null) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeByte(getPacketId()); write(out);//from ww w . j av a 2 s .c o m return PacketDispatcher.getPacket(PaleoPacketHandler.CHANNEL_NAME, out.toByteArray()); } throw new IllegalArgumentException("You have to define a channel for the PowerGrid packets first!"); }
From source file:eplus.network.packets.BasePacket.java
/** * Writes all data to and finalizes the packet * * @return Finalized packet/*from ww w. java2 s . c om*/ */ public final Packet makePacket() { ByteArrayDataOutput output = ByteStreams.newDataOutput(); output.writeByte(getPacketId()); write(output); return PacketDispatcher.getPacket(CHANNEL, output.toByteArray()); }
From source file:com.netflix.suro.message.MessageSerDe.java
@Override public byte[] serialize(Message payload) { try {/*from www . ja va 2 s . co m*/ ByteArrayDataOutput out = new ByteArrayDataOutputStream(outputStream.get()); out.writeByte(Message.classMap.inverse().get(payload.getClass())); payload.write(out); return out.toByteArray(); } catch (IOException e) { log.error("Exception on serialize: " + e.getMessage(), e); return new byte[] {}; } }
From source file:org.lambda3.indra.util.VectorIterator.java
private void parseHeadline(LittleEndianDataInputStream input) throws IOException { ByteArrayDataOutput out = ByteStreams.newDataOutput(); byte c;/*from ww w. jav a 2 s .co m*/ while ((c = input.readByte()) != '\n') { out.writeByte(c); } String[] headline = new String(out.toByteArray(), StandardCharsets.UTF_8).split(" "); this.numberOfVectors = Integer.parseInt(headline[0]); this.dimensions = Integer.parseInt(headline[1]); }
From source file:de.mineformers.powergrid.network.packet.PacketSyncCable.java
@Override public void write(ByteArrayDataOutput out) { out.writeInt(x);//from w w w. j a va 2s .co m out.writeInt(y); out.writeInt(z); out.writeInt(connections.size()); for (ForgeDirection dir : connections) { out.writeByte(dir.ordinal()); } }
From source file:org.lambda3.indra.util.VectorIterator.java
private void setCurrentContent() throws IOException { if (numberOfVectors > 0) { numberOfVectors--;//w w w.j av a2 s . c o m ByteArrayDataOutput out = ByteStreams.newDataOutput(); byte b; while ((b = input.readByte()) != ' ') { out.writeByte(b); } String word = new String(out.toByteArray(), StandardCharsets.UTF_8); if (this.sparse) { this.currentVector = new TermVector(true, word, readSparseVector(this.dimensions)); } else { this.currentVector = new TermVector(false, word, readDenseVector(this.dimensions)); } } else { this.currentVector = null; } }
From source file:cpw.mods.fml.common.network.ModListRequestPacket.java
@Override public byte[] generatePacket(Object... data) { ByteArrayDataOutput dat = ByteStreams.newDataOutput(); Set<ModContainer> activeMods = FMLNetworkHandler.instance().getNetworkModList(); dat.writeInt(activeMods.size());/*from w ww. ja v a 2 s .c om*/ for (ModContainer mc : activeMods) { dat.writeUTF(mc.getModId()); } dat.writeByte(FMLNetworkHandler.getCompatibilityLevel()); return dat.toByteArray(); }
From source file:pw.simplyintricate.bitcoin.models.datastructures.NetworkAddress.java
public byte[] toByteArray() { ByteArrayDataOutput writer = ByteStreams.newDataOutput(); //writer.writeInt(EndianUtils.swapInteger(time)); writer.writeLong(EndianUtils.swapLong(services.longValue())); // write the two ipv4 to ipv6 pads for (int i = 0; i < 10; i++) { writer.writeByte(0); }//from w w w . j a v a 2 s. c o m writer.writeByte(0xFF); writer.writeByte(0xFF); writer.write(ipAddress); writer.writeShort(port); return writer.toByteArray(); }
From source file:codecrafter47.bungeetablistplus.bridge.BukkitBridge.java
@SneakyThrows private void initializeHandshake(Server server) { ByteArrayDataOutput data = ByteStreams.newDataOutput(); data.writeByte(BridgeProtocolConstants.MESSAGE_ID_PROXY_HANDSHAKE); DataStreamUtils.writeUUID(data, proxyId); data.writeInt(BridgeProtocolConstants.VERSION); server.sendData(BridgeProtocolConstants.CHANNEL, data.toByteArray()); }
From source file:io.github.aritzhack.aritzh.bds.BDSCompound.java
private byte[] getUncompressedBytes() { ByteArrayDataOutput output = ByteStreams.newDataOutput(); output.writeByte(this.getType().toByte()); output.writeUTF(this.name); for (BDS bds : this.items) { if (bds instanceof BDSCompound) { output.write(((BDSCompound) bds).getUncompressedBytes()); } else//from ww w . j av a 2 s .c o m output.write(bds.getBytes()); } output.write(new BDSCompEnd().getBytes()); return output.toByteArray(); }