Skip to content

Commit

Permalink
Merge branch 'develop' into mdnsuuid
Browse files Browse the repository at this point in the history
  • Loading branch information
jonknight73 committed Feb 7, 2020
2 parents 24e6af1 + 06271b8 commit 8b9d9e8
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 8 deletions.
17 changes: 13 additions & 4 deletions CHANGELOG.md
@@ -1,20 +1,29 @@
# CHANGELOG

## TBA (February, 2020)
## v0.3.1 (TBA February, 2020)

SECURITY:

FEATURES:

IMPROVEMENTS:

- The NSD component now uses a string of random digits as the advertised group name
and contains a TXT field with the user defined group name, group UID and app UID.
This enables a set of advertised services to be partitioned into sets of
- babble library: renamed configuration functions to be less ambiguous
- discovery: The NSD component now uses a string of random digits as the advertised
group name and contains a TXT field with the user defined group name, group UID and
app UID. This enables a set of advertised services to be partitioned into sets of
services which represent the same group.
- archive: Amended to show all versions
- configuration: Added global config options to ConfigManager with sample code in comments in
sample/MainActivity.java
- sample app: Added labels to other person's speech to highlight who said what.
- sample app: Added announcements when people join and leave

BUG FIXES:

- babble: Add support for build target API 29 (Android Q) which previously failed


## v0.3.0 (January 31, 2020)

SECURITY:
Expand Down
Expand Up @@ -53,13 +53,13 @@ public static final class Builder {
private int mHeartbeat = 10;
private int mSlowHeartbeat = 10;
private boolean mStore = true;
private String mLogLevel = "debug";
private String mLogLevel = "info";
private int mTcpTimeout = 1000;
private int mMaxPool = 2;
private int mCacheSize = 50000;
private int mSyncLimit = 1000;
private boolean mEnableFastSync = false;
private boolean mBootstrap = true; //bootstrap
private boolean mBootstrap = false; //bootstrap
private String mServiceListen = ""; //service-listen
private String mJoinTimeout = "20s"; //join_timeout
private boolean mMaintenanceMode = false; //maintenance-mode
Expand Down
16 changes: 15 additions & 1 deletion sample/src/main/java/io/mosaicnetworks/sample/ChatActivity.java
Expand Up @@ -35,6 +35,7 @@
import com.stfalcon.chatkit.messages.MessagesList;
import com.stfalcon.chatkit.messages.MessagesListAdapter;

import java.util.ArrayList;
import java.util.List;

import io.mosaicnetworks.babble.node.ServiceObserver;
Expand Down Expand Up @@ -107,7 +108,20 @@ public void stateUpdated() {

Log.i("ChatActivity", "stateUpdated");

final List<Message> newMessages = mMessagingService.state.getMessagesFromIndex(mMessageIndex);

List<Message> newMessagesTemp = new ArrayList<>();

for (Message m : mMessagingService.state.getMessagesFromIndex(mMessageIndex)) {

if (m.author.equals(mMoniker)) {
newMessagesTemp.add(m);
} else {
newMessagesTemp.add(new Message(m.author+ ":\n" + m.text, m.author, m.date));
}

}

final List<Message> newMessages = newMessagesTemp;

runOnUiThread(new Runnable() {
@Override
Expand Down
11 changes: 10 additions & 1 deletion sample/src/main/java/io/mosaicnetworks/sample/ChatState.java
Expand Up @@ -54,7 +54,6 @@ public Block processBlock(Block block) {
// Process regular transactions
for (byte[] rawTx:block.body.transactions) {
String tx = new String(rawTx, StandardCharsets.UTF_8);

Message msg;
try {
msg = Message.fromJson(tx);
Expand All @@ -71,6 +70,16 @@ public Block processBlock(Block block) {
InternalTransactionReceipt[] itr = new InternalTransactionReceipt[block.body.internalTransactions.length];
for(int i=0; i< block.body.internalTransactions.length; i++){
itr[i] = block.body.internalTransactions[i].asAccepted();
Message msg;

if (block.body.internalTransactions[i].body.type == 0 ) {
msg = new Message(block.body.internalTransactions[i].body.peer.moniker + " joined the group", "System");
} else {
msg = new Message(block.body.internalTransactions[i].body.peer.moniker + " left the group", "System");
}
mState.put(mNextIndex, msg);
mNextIndex++;

}

// Set block stateHash and receipts
Expand Down
15 changes: 15 additions & 0 deletions sample/src/main/java/io/mosaicnetworks/sample/Message.java
Expand Up @@ -93,6 +93,21 @@ public Message(String text, String author) {
this.date = new Date();
}


/**
* Constructor
* @param text the message text
* @param author the message author
* @param date the message date
*/
public Message(String text, String author, Date date) {
this.text = text;
this.author = author;
this.date = date;
}



/**
* Factory for constructing a {@link Message} from JSON
* @param txJson A JSON format transaction string
Expand Down

0 comments on commit 8b9d9e8

Please sign in to comment.