out.write(getChecksum(payloadBytes)); } catch (GeneralSecurityException e) { throw new RuntimeException(e);
@Override public void write(OutputStream out) throws IOException { // magic Encode.int32(MAGIC, out); // ASCII string identifying the packet content, NULL padded (non-NULL padding results in packet rejected) String command = payload.getCommand().name().toLowerCase(); out.write(command.getBytes("ASCII")); for (int i = command.length(); i < 12; i++) { out.write('\0'); } byte[] payloadBytes = Encode.bytes(payload); // Length of payload in number of bytes. Because of other restrictions, there is no reason why this length would // ever be larger than 1600003 bytes. Some clients include a sanity-check to avoid processing messages which are // larger than this. Encode.int32(payloadBytes.length, out); // checksum try { out.write(getChecksum(payloadBytes)); } catch (GeneralSecurityException e) { throw new ApplicationException(e); } // message payload out.write(payloadBytes); }
out.put(getChecksum(payloadBytes)); } catch (GeneralSecurityException e) { throw new ApplicationException(e);