Skip to content

Commit 4cc94ef

Browse files
committed
added parameter asapHop to any assimilate method variant
1 parent 144683f commit 4cc94ef

File tree

5 files changed

+31
-27
lines changed

5 files changed

+31
-27
lines changed

src/net/sharksystem/asap/engine/ASAPOnlineMessageSenderEngineSide.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ public void sendASAPAssimilateMessage(CharSequence format, CharSequence uri, byt
5151
this.sendASAPAssimilateMessage(format, uri, onlinePeerList, messageAsBytes, era);
5252
}
5353

54-
public void sendASAPAssimilateMessage(CharSequence format, CharSequence uri, Set<CharSequence> recipients,
54+
public void sendASAPAssimilateMessage(CharSequence format, CharSequence uri, Set<CharSequence> receiver,
5555
byte[] messageAsBytes, int era) throws IOException, ASAPException {
5656

57-
if(recipients == null || recipients.size() < 1) {
57+
if(receiver == null || receiver.size() < 1) {
5858
// replace empty recipient list with list of online peers.
5959
this.sendASAPAssimilateMessage(format, uri, messageAsBytes, era);
6060
return;
@@ -67,19 +67,19 @@ public void sendASAPAssimilateMessage(CharSequence format, CharSequence uri, Set
6767
sb.append(uri);
6868
sb.append("| era: ");
6969
sb.append(era);
70-
sb.append("| #recipients: ");
71-
if(recipients != null) sb.append(recipients.size());
70+
sb.append("| #receiver: ");
71+
if(receiver != null) sb.append(receiver.size());
7272
else sb.append("null");
7373
sb.append("| length: ");
7474
sb.append(messageAsBytes.length);
7575
sb.append(")");
7676
System.out.println(sb.toString());
7777

78-
// each message can have multiple recipients. Iterate
78+
// each message can have multiple receiver. Iterate
7979

80-
// is there an open connection to each of the recipients.
80+
// is there an open connection to each of the receiver.
8181
boolean foundAll = true; // optimism captain :)
82-
for(CharSequence recipient : recipients) {
82+
for(CharSequence recipient : receiver) {
8383
sb = Log.startLog(this);
8484
sb.append("try to find connection for recipient: ");
8585
sb.append(recipient);
@@ -93,7 +93,7 @@ public void sendASAPAssimilateMessage(CharSequence format, CharSequence uri, Set
9393
// serialize message for this recipient
9494
ByteArrayOutputStream asapPDUBytes = new ByteArrayOutputStream();
9595
protocol.assimilate(this.multiEngine.getOwner(), recipient, format, uri, era, null, // no offsets
96-
messageAsBytes, asapPDUBytes, asapConnection.isSigned());
96+
null, messageAsBytes, asapPDUBytes, asapConnection.isSigned());
9797

9898
// I guess maps are synchronized
9999
List<byte[]> messageList = this.messages.get(recipient);

src/net/sharksystem/asap/protocol/ASAP_1_0.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void interest(CharSequence sender, CharSequence format, CharSequence sourcePeer,
157157
* @throws ASAPException protocol exception: mandatory parameter missing, invalid combination of parameters, ..
158158
*/
159159
void assimilate(CharSequence sender, CharSequence recipient, CharSequence format, CharSequence channelUri, int era,
160-
long length, List<Long> offsets, InputStream dataIS, OutputStream os, boolean signed)
160+
long length, List<Long> offsets, List<ASAPHop> asapHops, InputStream dataIS, OutputStream os, boolean signed)
161161
throws IOException, ASAPException;
162162

163163

@@ -182,7 +182,8 @@ void assimilate(CharSequence sender, CharSequence recipient, CharSequence format
182182
* @throws ASAPException protocol exception: mandatory parameter missing, invalid combination of parameters, ..
183183
*/
184184
void assimilate(CharSequence sender, CharSequence recipient, CharSequence format, CharSequence channelUri, int era,
185-
long length, List<Long> offsets, InputStream dataIS, OutputStream os, boolean signed, boolean encrypted)
185+
long length, List<Long> offsets, List<ASAPHop> asapHops,
186+
InputStream dataIS, OutputStream os, boolean signed, boolean encrypted)
186187
throws IOException, ASAPException;
187188

188189
/**
@@ -200,7 +201,7 @@ void assimilate(CharSequence sender, CharSequence recipient, CharSequence format
200201
* @throws ASAPException protocol exception: mandatory parameter missing, invalid combination of parameters, ..
201202
*/
202203
void assimilate(CharSequence sender, CharSequence recipient, CharSequence format, CharSequence channel, int era,
203-
List<Long> offsets, byte[] data, OutputStream os, boolean signed)
204+
List<Long> offsets, List<ASAPHop> asapHops, byte[] data, OutputStream os, boolean signed)
204205
throws IOException, ASAPException;
205206

206207
/**
@@ -219,7 +220,7 @@ void assimilate(CharSequence sender, CharSequence recipient, CharSequence format
219220
* @throws ASAPException protocol exception: mandatory parameter missing, invalid combination of parameters, ..
220221
*/
221222
void assimilate(CharSequence sender, CharSequence recipient, CharSequence format, CharSequence channel, int era,
222-
List<Long> offsets, byte[] data, OutputStream os, boolean signed, boolean encrypted)
223+
List<Long> offsets, List<ASAPHop> asapHops, byte[] data, OutputStream os, boolean signed, boolean encrypted)
223224
throws IOException, ASAPException;
224225

225226

src/net/sharksystem/asap/protocol/ASAP_Modem_Impl.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,23 @@ public void interest(CharSequence sender, CharSequence recipient, CharSequence f
140140

141141
@Override
142142
public void assimilate(CharSequence sender, CharSequence recipient, CharSequence format,
143-
CharSequence channel, int era, long length, List<Long> offsets, InputStream dataIS,
143+
CharSequence channel, int era, long length, List<Long> offsets, List<ASAPHop> asapHops,
144+
InputStream dataIS,
144145
OutputStream os, boolean signed) throws IOException, ASAPException {
145146

146147
this.assimilate(sender, recipient, format, channel, era, length,
147-
offsets, dataIS, os, signed, false);
148+
offsets, asapHops, dataIS, os, signed, false);
148149
}
149150

150151
@Override
151-
public void assimilate(CharSequence sender, CharSequence recipient, CharSequence format,
152+
public void assimilate(CharSequence sender, CharSequence receiver, CharSequence format,
152153
CharSequence channel, int era, long length, List<Long> offsets, List<ASAPHop> asapHops,
153154
InputStream dataIS, OutputStream os,
154155
ASAPPoint2PointCryptoSettings secureSetting)
155156

156157
throws IOException, ASAPException {
157158

158-
this.assimilate(sender, recipient, format, channel, era, length, offsets, dataIS, os,
159+
this.assimilate(sender, receiver, format, channel, era, length, offsets, asapHops, dataIS, os,
159160
secureSetting.mustSign(), secureSetting.mustEncrypt());
160161
}
161162

@@ -164,7 +165,8 @@ public void assimilate(CharSequence sender, CharSequence recipient, CharSequence
164165
*/
165166
@Override
166167
public void assimilate(CharSequence sender, CharSequence recipient, CharSequence format,
167-
CharSequence channel, int era, long length, List<Long> offsets, InputStream dataIS,
168+
CharSequence channel, int era, long length, List<Long> offsets, List<ASAPHop> asapHops,
169+
InputStream dataIS,
168170
OutputStream os, boolean signed, boolean encrypted) throws IOException, ASAPException {
169171

170172
// prepare encryption and signing if required
@@ -175,29 +177,29 @@ public void assimilate(CharSequence sender, CharSequence recipient, CharSequence
175177
cryptoMessage.sendCmd();
176178

177179
AssimilationPDU_Impl.sendPDUWithoutCmd(sender, recipient, format, channel, era,
178-
length, offsets, dataIS, cryptoMessage.getOutputStream(), signed);
180+
length, offsets, asapHops, dataIS, cryptoMessage.getOutputStream(), signed);
179181

180182
// finish crypto session - maybe nothing has to be done
181183
cryptoMessage.finish();
182184
}
183185

184186
@Override
185187
public void assimilate(CharSequence sender, CharSequence recipient, CharSequence format,
186-
CharSequence channel, int era, List<Long> offsets, byte[] data,
188+
CharSequence channel, int era, List<Long> offsets, List<ASAPHop> asapHops, byte[] data,
187189
OutputStream os, boolean signed) throws IOException, ASAPException {
188190

189-
this.assimilate(sender, recipient, format, channel, era, offsets, data, os, signed, false);
191+
this.assimilate(sender, recipient, format, channel, era, offsets, asapHops, data, os, signed, false);
190192
}
191193

192194
@Override
193195
public void assimilate(CharSequence sender, CharSequence recipient, CharSequence format,
194-
CharSequence channel, int era, List<Long> offsets, byte[] data,
196+
CharSequence channel, int era, List<Long> offsets, List<ASAPHop> asapHops, byte[] data,
195197
OutputStream os, boolean signed, boolean encrypted) throws IOException, ASAPException {
196198

197199
if(data == null || data.length == 0) throw new ASAPException("data must not be null");
198200
if(era < 0) throw new ASAPException("era must be a non-negative value: " + era);
199201

200-
this.assimilate(sender, recipient, format, channel, era, data.length, offsets,
202+
this.assimilate(sender, recipient, format, channel, era, data.length, offsets, asapHops,
201203
new ByteArrayInputStream(data), os, signed, encrypted);
202204
}
203205

src/net/sharksystem/asap/protocol/AssimilationPDU_Impl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.sharksystem.asap.protocol;
22

33
import net.sharksystem.asap.ASAPException;
4+
import net.sharksystem.asap.ASAPHop;
45
import net.sharksystem.asap.utils.ASAPSerialization;
56

67
import java.io.*;
@@ -51,7 +52,7 @@ private void readRecipientPeer(InputStream is) throws IOException, ASAPException
5152
}
5253

5354
static void sendPDUWithoutCmd(CharSequence peer, CharSequence recipient, CharSequence format, CharSequence channel,
54-
int era, long length, List<Long> offsets, InputStream is, OutputStream os,
55+
int era, long length, List<Long> offsets, List<ASAPHop> asapHops, InputStream is, OutputStream os,
5556
boolean signed)
5657
throws IOException, ASAPException {
5758

test/net/sharksystem/asap/protocol/PDUTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public void sendAndReceiveAssimilate() throws IOException, ASAPException {
288288

289289
ByteArrayOutputStream os = new ByteArrayOutputStream();
290290

291-
protocolEngine.assimilate(sender, recipient, format, channel, era, offsetsList, data, os,false);
291+
protocolEngine.assimilate(sender, recipient, format, channel, era, offsetsList, null, data, os,false);
292292

293293
// try t read output
294294
InputStream is = new ByteArrayInputStream(os.toByteArray());
@@ -360,7 +360,7 @@ public void sendAndReceiveAssimilateSignedAndEncrypted() throws IOException, ASA
360360
ByteArrayOutputStream os = new ByteArrayOutputStream();
361361

362362

363-
asapModemAlice.assimilate(sender, recipient, format, channel, era, offsetsList, data, os,
363+
asapModemAlice.assimilate(sender, recipient, format, channel, era, offsetsList, null, data, os,
364364
true, true);
365365

366366
// try t read output
@@ -433,7 +433,7 @@ public void sendAndReceiveAssimilateSigned() throws IOException, ASAPException {
433433
ByteArrayOutputStream os = new ByteArrayOutputStream();
434434

435435

436-
asapModemAlice.assimilate(sender, recipient, format, channel, era, offsetsList, data, os,
436+
asapModemAlice.assimilate(sender, recipient, format, channel, era, offsetsList, null, data, os,
437437
true, false);
438438

439439
// try t read output
@@ -536,7 +536,7 @@ public void sendAndReceiveAssimilateEncrypted() throws IOException, ASAPExceptio
536536
ByteArrayOutputStream os = new ByteArrayOutputStream();
537537

538538

539-
asapModemAlice.assimilate(sender, recipient, format, channel, era, offsetsList, data, os,
539+
asapModemAlice.assimilate(sender, recipient, format, channel, era, offsetsList, null, data, os,
540540
false, true);
541541

542542
// try t read output

0 commit comments

Comments
 (0)