Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
encounters
EncounterBasedCommunication
Commits
0cb312d6
Commit
0cb312d6
authored
Jul 06, 2018
by
Lily Tsai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create topics with eid instead of ss
parent
d0647cf8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
testapp/src/main/java/org/mpisws/testapp/simulator/SimulationServerBT.java
...java/org/mpisws/testapp/simulator/SimulationServerBT.java
+9
-5
testapp/src/main/java/org/mpisws/testapp/simulator/SimulatorScannerProcessor.java
...g/mpisws/testapp/simulator/SimulatorScannerProcessor.java
+2
-1
No files found.
testapp/src/main/java/org/mpisws/testapp/simulator/SimulationServerBT.java
View file @
0cb312d6
...
...
@@ -13,6 +13,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
import
org.apache.commons.lang3.tuple.Pair
;
import
org.mpisws.embeddedsocial.ESClient
;
import
org.mpisws.embeddedsocial.ESMessage
;
import
org.mpisws.helpers.Coder
;
import
org.mpisws.helpers.Identifier
;
import
org.mpisws.messaging.EpochLinkMessage
;
...
...
@@ -93,22 +94,25 @@ public class SimulationServerBT {
}).
start
();
}
private
void
processData
()
{
Looper
.
prepare
();
Handler
handler
=
new
Handler
();
// Create all topics you'll ever have to create
List
<
Pair
<
Identifier
,
Identifier
>>
topicsToCreate
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
nonces
.
size
();
i
++)
{
topicsToCreate
.
add
(
new
ImmutablePair
<>(
nonces
.
get
(
i
),
pubKeys
.
get
(
i
)));
}
for
(
Identifier
ss
:
sharedSecrets
)
{
topicsToCreate
.
add
(
new
ImmutablePair
<>(
ss
,
ss
));
topicsToCreate
.
add
(
new
ImmutablePair
<>(
Coder
.
convertSharedSecretToID
(
ss
)
,
Coder
.
convertSharedSecretToID
(
ss
))
)
;
}
Log
.
d
(
TAG
,
"
c
reating nonce and shared secret topics: "
+
topicsToCreate
.
size
());
Log
.
d
(
TAG
,
"
C
reating nonce and shared secret topics: "
+
topicsToCreate
.
size
());
ESClient
.
getInstance
().
createTopics
(
topicsToCreate
);
// Every "epoch" or so try to post link messages to the prior "epoch" ss for each "device"
// Let's try and post to the prior 3 epochs
Looper
.
prepare
();
for
(
int
loop
=
1
;
loop
<=
NUM_SIMULATED_EPOCHS
;
loop
++)
{
new
Handler
().
postDelayed
(()
->
{
Log
.
d
(
TAG
,
"Handler loop "
+
loop
);
handler
.
postDelayed
(()
->
{
Log
.
d
(
TAG
,
"Handler loop!"
);
int
lowEpoch
=
currentEpoch
>
3
?
currentEpoch
-
3
:
0
;
List
<
Identifier
>
sses
=
sharedSecrets
.
subList
(
lowEpoch
*
NUM_SIMULATED_DEVICES
,
currentEpoch
*
NUM_SIMULATED_DEVICES
);
List
<
String
>
topicHandles
=
ESClient
.
getInstance
().
getTopicHandles
(
sses
);
...
...
@@ -126,7 +130,7 @@ public class SimulationServerBT {
.
addNewNonce
(
nonces
.
get
((
lowEpoch
*
NUM_SIMULATED_DEVICES
)
+
newIndex
).
toString
())
.
build
();
msgsToSend
.
add
(
new
ESMessage
(
epochLinkMessage
.
toSendMessageText
(
sses
.
get
(
oldIndex
).
getBytes
()),
new
Identifier
(
SHA1
(
sharedSecrets
.
get
(
i
)
.
getBytes
())
).
toString
(),
Coder
.
convertSharedSecretToID
(
sharedSecrets
.
get
(
i
)).
toString
(),
topicHandles
.
get
(
oldIndex
),
true
,
null
,
true
,
-
1
));
}
...
...
testapp/src/main/java/org/mpisws/testapp/simulator/SimulatorScannerProcessor.java
View file @
0cb312d6
...
...
@@ -115,6 +115,7 @@ public class SimulatorScannerProcessor {
*/
private
class
SDDRScanCallback
extends
ScanCallback
{
private
void
simulateReceivingResults
()
{
Log
.
d
(
TAG
,
"CURRENT EPOCH: "
+
CURRENT_EPOCH
);
// get all "new" nonces you should've "received"
for
(
int
i
=
0
;
i
<
NUM_SIMULATED_DEVICES
;
i
++)
{
// for each new nonce, call processScanResult
...
...
@@ -138,7 +139,7 @@ public class SimulatorScannerProcessor {
@Override
public
void
onScanResult
(
int
callbackType
,
ScanResult
result
)
{
super
.
onScanResult
(
callbackType
,
result
);
Log
.
v
(
TAG
,
"
s
ome scan result"
);
Log
.
v
(
TAG
,
"
S
ome scan result"
);
SDDR_Native
.
c_preDiscovery
();
simulateReceivingResults
();
SDDR_Native
.
c_postDiscovery
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment