Skip to content

Commit 2870ce8

Browse files
committed
certificates are nearly exchanged with online connection stuff.
1 parent b251b7c commit 2870ce8

15 files changed

Lines changed: 152 additions & 235 deletions

src/net/sharksystem/asap/ASAPAbstractOnlineMessageSender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void attachToSource(ASAPStorage source) {
1717

1818
public void detachFromStorage() {
1919
if(this.source != null) {
20-
this.source.detachASAPMessageAddListener(this);
20+
this.source.detachASAPMessageAddListener();
2121
}
2222
}
2323

src/net/sharksystem/asap/ASAPChunk.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public interface ASAPChunk {
9292
* @throws IOException
9393
* @deprecated
9494
*/
95-
void addMessage(CharSequence message) throws IOException;
95+
//void addMessage(CharSequence message) throws IOException;
9696

9797
void addMessage(byte[] messageAsBytes) throws IOException;
9898

src/net/sharksystem/asap/ASAPChunkFS.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,12 @@ public String getUri() {
143143
return (String) this.uri;
144144
}
145145

146+
/*
146147
@Override
147148
public void addMessage(CharSequence message) throws IOException {
148149
this.addMessage(message.toString().getBytes());
149150
}
150-
151+
*/
151152
@Override
152153
public void addMessage(byte[] messageAsBytes) throws IOException {
153154
if(messageAsBytes.length > Integer.MAX_VALUE) {

src/net/sharksystem/asap/ASAPChunkStorageFS.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import net.sharksystem.Utils;
44
import net.sharksystem.asap.apps.ASAPMessages;
5+
import net.sharksystem.asap.util.Log;
56

67
import java.io.File;
78
import java.io.FilenameFilter;
@@ -26,7 +27,11 @@ class ASAPChunkStorageFS implements ASAPChunkStorage {
2627
}
2728

2829
public String getFormat() {
29-
return format;
30+
return this.format;
31+
}
32+
33+
public String getRootDirectory() {
34+
return this.rootDirectory;
3035
}
3136

3237
@Override
@@ -38,7 +43,8 @@ public ASAPChunk getChunk(CharSequence uriTarget, int era) throws IOException {
3843
public boolean existsChunk(CharSequence uri, int era) throws IOException {
3944
String fullContentFileName = this.getChunkContentFilename(era, uri);
4045

41-
return(new File(fullContentFileName).exists());
46+
boolean exists = (new File(fullContentFileName).exists());
47+
return exists;
4248
}
4349

4450
String getChunkContentFilename(int era, CharSequence uri) {
@@ -128,6 +134,8 @@ public ASAPMessages getASAPChunkCache(CharSequence uri, int toEra) throws IOExce
128134
fromEra = ASAPEngine.previousEra(fromEra);
129135
}
130136

137+
Log.writeLog(this, "create ASAPInMemoMessages");
138+
131139
return new ASAPInMemoMessages(this,
132140
this.getFormat(),
133141
uri,

src/net/sharksystem/asap/ASAPEngine.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void attachASAPMessageAddListener(ASAPOnlineMessageSender asapOnlineMessa
6868
this.asapOnlineMessageSender = asapOnlineMessageSender;
6969
}
7070

71-
public void detachASAPMessageAddListener(ASAPOnlineMessageSender asapOnlineMessageSender) {
71+
public void detachASAPMessageAddListener() {
7272
this.asapOnlineMessageSender = null;
7373
}
7474

@@ -213,7 +213,7 @@ private ASAPChannelImpl getASAPChannelImpl(CharSequence uri) throws ASAPExceptio
213213
return new ASAPChannelImpl(this, uri);
214214
}
215215

216-
throw new ASAPException("channel with does not exist: " + uri);
216+
throw new ASAPException("channel with this uri does not exist: " + uri);
217217
}
218218

219219
@Override
@@ -264,13 +264,15 @@ private String getLogStart() {
264264
StringBuilder b = new StringBuilder();
265265
b.append("ASAPEngine (");
266266
b.append(this.owner);
267+
b.append(", format: ");
268+
b.append(this.format);
267269
b.append(", era: ");
268270
b.append(this.era);
269271
b.append("): ");
270272

271273
return b.toString();
272274
}
273-
275+
/*
274276
public void handleConnection(InputStream is, OutputStream os,
275277
ASAPChunkReceivedListener listener) {
276278
@@ -291,17 +293,17 @@ public void handleConnection(InputStream is, OutputStream os,
291293
292294
this.handleASAPInterest((ASAP_Interest_PDU_1_0) asapPDU, protocol, os);
293295
}
294-
catch(Exception ioe) {
296+
catch(Exception e) {
295297
//<<<<<<<<<<<<<<<<<<debug
296298
StringBuilder b = new StringBuilder();
297299
b.append(this.getLogStart());
298-
b.append("IOEXception: ");
299-
b.append(ioe.getLocalizedMessage());
300+
b.append("Exception: ");
301+
b.append(e.getLocalizedMessage());
300302
System.out.println(b.toString());
301303
//>>>>>>>>>>>>>>>>>>>debug
302304
}
303305
}
304-
306+
*/
305307
public void handleASAPOffer(ASAP_OfferPDU_1_0 asapOffer, ASAP_1_0 protocol, OutputStream os)
306308
throws ASAPException, IOException {
307309

src/net/sharksystem/asap/ASAPInMemoMessages.java

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

33
import net.sharksystem.asap.apps.ASAPMessages;
4+
import net.sharksystem.asap.util.Log;
45
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
56

67
import java.io.IOException;
@@ -39,6 +40,10 @@ public ASAPInMemoMessages(ASAPChunkStorageFS chunkStorage,
3940
this.fromEra = fromEra;
4041
this.toEra = toEra;
4142
this.maxCacheLen = maxCacheLen;
43+
44+
Log.writeLog(this, "format: " + format + "uri: " + uri
45+
+ "rootDir: " + chunkStorage.getRootDirectory()
46+
+ "fromEra: " + fromEra+ "toEra: " + toEra+ "maxCacheLen: " + maxCacheLen);
4247
}
4348

4449
public ASAPInMemoMessages(ASAPChunkStorageFS chunkStorage,

src/net/sharksystem/asap/ASAPOnlineMessageSenderEngineSide.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public void sendASAPAssimilate(CharSequence format, CharSequence uri, Set<CharSe
4949
byte[] messageAsBytes, int era) throws IOException, ASAPException {
5050

5151
if(recipients == null || recipients.size() < 1) {
52+
// replace empty recipient list with list of online peers.
5253
this.sendASAPAssimilate(format, uri, messageAsBytes, era);
5354
}
5455

@@ -109,7 +110,7 @@ public void sendASAPAssimilate(CharSequence format, CharSequence uri, Set<CharSe
109110
}
110111

111112
private String getLogStart() {
112-
return this.getClass().getSimpleName();
113+
return this.getClass().getSimpleName() + ": ";
113114
}
114115

115116
@Override

src/net/sharksystem/asap/ASAPSingleProcessOnlineMessageSender.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public ASAPSingleProcessOnlineMessageSender(MultiASAPEngineFS multiEngine, ASAPS
2121
public void sendASAPAssimilate(CharSequence format, CharSequence uri, Set<CharSequence> recipients,
2222
byte[] messageAsBytes, int era) throws IOException, ASAPException {
2323

24-
this.asapOnlineMessageSenderEngineSide.sendASAPAssimilate(format, uri, recipients, messageAsBytes, era);
24+
this.asapOnlineMessageSenderEngineSide.sendASAPAssimilate(
25+
format, uri, recipients, messageAsBytes, era);
2526
}
2627

2728
@Override

src/net/sharksystem/asap/ASAPStorage.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010

1111
/**
1212
*
13-
* Communication break down in ad-hoc networks is normal and no failure.
13+
* Break down of a communication channel in ad-hoc networks is normal and barely failure.
1414
* That chunk storage is meant to keep messages which are produced by an
1515
* app for later transmission.
1616
*
1717
* Messages which cannot be sent to their recipients can be stored in ASAP chunks.
1818
* Each chunk is addressed with an URI (comparable to URIs e.g. in Android
1919
* Content Provider)
2020
*
21-
* Applications can easlily store their messages by calling add(URI, message).
21+
* Applications can easily store their messages by calling add(URI, message).
2222
* That message is stored in a chunk addressed by the URI.
2323
*
2424
* Each chunk has a recipient list which can be changed anytime. The ASAPEngine
@@ -33,7 +33,7 @@
3333
* ASAPStorage myStorage = ASAPEngineFS.getASAPEngine("EngineName", "ChunkStorageRootFolder", reader);
3434
* </pre>
3535
*
36-
* An AASPReader must be implemented prior using that framework. Objects of
36+
* An ASAPReader must be implemented prior using that framework. Objects of
3737
* that class are called whenever another peer transmits messages to the
3838
* local peer. @see AASPReader
3939
*
@@ -43,7 +43,7 @@
4343
* current era is declared to be finished and an new era is opened.
4444
* Any new message is now tagged as message from that new era. The ASAPEngine
4545
* transmits all message to the peer which are stored after the final
46-
* encounter. If no encounter ever happened - all availablee messages are
46+
* encounter. If no encounter ever happened - all available messages are
4747
* transmitted.
4848
*
4949
* @see ASAPEngine
@@ -177,7 +177,7 @@ public interface ASAPStorage {
177177

178178
void attachASAPMessageAddListener(ASAPOnlineMessageSender asapOnlineMessageSender);
179179

180-
void detachASAPMessageAddListener(ASAPOnlineMessageSender asapOnlineMessageSender);
180+
void detachASAPMessageAddListener();
181181

182182
void setASAPManagementStorage(ASAPManagementStorage asapManagementStorage);
183183

src/net/sharksystem/asap/MultiASAPEngineFS.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,7 @@ public interface MultiASAPEngineFS {
8787
* @return all formats currently supported by this mulit engine
8888
*/
8989
Set<CharSequence> getFormats();
90+
91+
void activateOnlineMessages();
92+
void deactivateOnlineMessages();
9093
}

0 commit comments

Comments
 (0)