summaryrefslogtreecommitdiff
path: root/src/org/noreply/fancydress/type3/Payload.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/noreply/fancydress/type3/Payload.java')
-rw-r--r--src/org/noreply/fancydress/type3/Payload.java49
1 files changed, 18 insertions, 31 deletions
diff --git a/src/org/noreply/fancydress/type3/Payload.java b/src/org/noreply/fancydress/type3/Payload.java
index 16b1b57..73027cd 100644
--- a/src/org/noreply/fancydress/type3/Payload.java
+++ b/src/org/noreply/fancydress/type3/Payload.java
@@ -8,34 +8,10 @@ import org.noreply.fancydress.misc.Util;
import org.noreply.fancydress.type3.routing.*;
public class Payload {
- byte[] thisPayload;
-
- public Payload() {
- RoutingSMTP route = new RoutingSMTP("peter@palfrader.org");
- String body = "FROM:Peter\n" +
- "SUBJECT:test fancydress\n" +
- "\n" +
- "blubb\n";
-
- /*
- // Encode a String into bytes
- String inputString = "blahblahblah??";
- byte[] input = inputString.getBytes("UTF-8");
-
- // Compress the bytes
- byte[] output = new byte[100];
- Deflater compresser = new Deflater();
- compresser.setInput(input);
- compresser.finish();
- int compressedDataLength = compresser.deflate(output);
-
- // Decompress the bytes
- Inflater decompresser = new Inflater();
- decompresser.setInput(output, 0, compressedDataLength);
- byte[] result = new byte[100];
- int resultLength = decompresser.inflate(result);
- decompresser.end();
- */
+ byte[][] payloads;
+ RoutingDestination[] route;
+
+ public Payload(RoutingDestination route, String body) {
try {
PipedOutputStream poMessage = new PipedOutputStream();
PipedInputStream piMessage = new PipedInputStream( poMessage );
@@ -77,18 +53,29 @@ public class Payload {
if (pos != 28*1024)
throw new Error("did not fill in 28k bytes");
- thisPayload = payload;
+ payloads = new byte[1][];
+ payloads[0] = payload;
} catch (Exception e) {
throw new Error(e);
};
+ this.route = new RoutingDestination[1];
+ this.route[0] = route;
// Return a singleton payload containing:
// Flag 0 | Int(15,LEN(M_C)) | Hash(M_C | PADDING) | M_C | PADDING
}
- public byte[] asOctets() {
- return thisPayload;
+ public int numPackets() {
+ return payloads.length;
+ }
+
+ public byte[] getPayload(int i) {
+ return payloads[i];
+ }
+
+ public RoutingDestination getRoute(int i) {
+ return route[i];
}
}