Skip to content

Commit 49b6064

Browse files
committed
make interfaces a bit nicer - plan to make channel interface of choice for asap app message handling.
1 parent 8a895c8 commit 49b6064

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

src/net/sharksystem/asap/ASAPChannel.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ public interface ASAPChannel {
1010
Set<CharSequence> getRecipients() throws IOException;
1111
HashMap<String, String> getExtraData() throws IOException;
1212
ASAPChannelMessages getMessages() throws IOException;
13+
void addMessage(byte[] message) throws IOException;
1314
}

src/net/sharksystem/asap/ASAPChannelImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ public ASAPChannelMessages getMessages() throws IOException {
3939
return this.asapEngine.getChunkStorage().getASAPChunkCache(this.getUri(), this.asapEngine.getEra());
4040
}
4141

42+
@Override
43+
public void addMessage(byte[] message) throws IOException {
44+
this.asapEngine.add(this.uri, message);
45+
}
46+
4247
public void setOwner(CharSequence owner) throws IOException {
4348
this.asapEngine.putExtra(this.getUri(), CHANNEL_OWNER, owner.toString());
4449
}

src/net/sharksystem/asap/ASAPChannelMessages.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ public interface ASAPChannelMessages {
2424
*
2525
* @return number of messages fitting to that uri regardless of era
2626
*/
27-
public int getNumberMessage() throws IOException;
28-
27+
int getNumberMessage() throws IOException;
28+
int size() throws IOException;
29+
2930
/**
30-
*
31-
* @return uri of that chunk cache
31+
* @return channel uri
3232
*/
33-
public CharSequence getURI();
33+
CharSequence getURI();
3434

3535
/**
3636
*
@@ -63,7 +63,4 @@ CharSequence getMessage(int position, boolean chronologically)
6363
* @throws IOException
6464
*/
6565
void sync() throws IOException;
66-
67-
int size() throws IOException;
68-
6966
}

src/net/sharksystem/asap/ASAPStorage.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ public interface ASAPStorage {
100100
*/
101101
void createChannel(CharSequence urlTarget, CharSequence recipient) throws IOException, ASAPException;
102102

103+
void removeChannel(CharSequence uri) throws IOException;
104+
103105
/**
104106
* Chunks are delivered when seeing other peers. This flag allows to decide whether delivered chunks
105107
* are to be deleted.
@@ -167,9 +169,9 @@ public interface ASAPStorage {
167169
* @param message Message to be kept for later transmission
168170
* @throws IOException
169171
*/
170-
public void add(CharSequence urlTarget, CharSequence message) throws IOException;
172+
void add(CharSequence urlTarget, CharSequence message) throws IOException;
171173

172-
public void add(CharSequence urlTarget, byte[] messageAsBytes) throws IOException;
174+
void add(CharSequence urlTarget, byte[] messageAsBytes) throws IOException;
173175

174176
void attachASAPMessageAddListener(ASAPOnlineMessageSender asapOnlineMessageSender);
175177

@@ -215,7 +217,7 @@ public interface ASAPStorage {
215217
* @param era
216218
* @return
217219
*/
218-
public int getPreviousEra(int era);
220+
int getPreviousEra(int era);
219221

220222
/**
221223
* Default behaviour of ASAPEngine: Each peer / communication partner
@@ -225,24 +227,22 @@ public interface ASAPStorage {
225227
* @param sender
226228
* @return
227229
*/
228-
public ASAPChunkStorage getIncomingChunkStorage(CharSequence sender);
230+
ASAPChunkStorage getIncomingChunkStorage(CharSequence sender);
229231

230232
ASAPStorage getExistingIncomingStorage(CharSequence sender) throws IOException, ASAPException;
231233

232234
/**
233235
*
234236
* @return list of peers with an incoming chunk storage
235237
*/
236-
public List<CharSequence> getSender();
238+
List<CharSequence> getSender();
237239

238240
/**
239241
*
240242
* @return The local chunk storage that is meant to be used by the local
241-
* app. Note: That storage is changed during an AASP session.
243+
* app. Note: That storage is changed during an ASAP session.
242244
*/
243-
public ASAPChunkStorage getChunkStorage();
244-
245-
void removeChannel(CharSequence uri) throws IOException;
245+
ASAPChunkStorage getChunkStorage();
246246

247247
ASAPChannelMessages getChunkChain(int position) throws IOException, ASAPException;
248248

0 commit comments

Comments
 (0)