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
fa5f3f03
Commit
fa5f3f03
authored
Jul 06, 2018
by
Lily Tsai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handler still not working...
parent
0cb312d6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
31 deletions
+36
-31
testapp/src/main/java/org/mpisws/testapp/simulator/SimulationServerBT.java
...java/org/mpisws/testapp/simulator/SimulationServerBT.java
+36
-31
No files found.
testapp/src/main/java/org/mpisws/testapp/simulator/SimulationServerBT.java
View file @
fa5f3f03
...
...
@@ -94,8 +94,7 @@ public class SimulationServerBT {
}).
start
();
}
private
void
processData
()
{
Looper
.
prepare
();
Handler
handler
=
new
Handler
();
final
Handler
handler
=
new
Handler
(
Looper
.
getMainLooper
());
// Create all topics you'll ever have to create
List
<
Pair
<
Identifier
,
Identifier
>>
topicsToCreate
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
nonces
.
size
();
i
++)
{
...
...
@@ -109,13 +108,17 @@ public class SimulationServerBT {
// 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
for
(
int
loop
=
1
;
loop
<=
NUM_SIMULATED_EPOCHS
;
loop
++
)
{
Log
.
d
(
TAG
,
"Handler loop "
+
loop
);
handler
.
postDelaye
d
(()
->
{
Log
.
d
(
TAG
,
"
Handler loop
!"
);
handler
.
postDelayed
(
new
Runnable
(
)
{
public
void
run
()
{
new
Threa
d
(()
->
{
Log
.
d
(
TAG
,
"
Runnable
!"
);
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
);
List
<
Identifier
>
eids
=
new
ArrayList
<>();
for
(
Identifier
ss
:
sses
)
{
eids
.
add
(
Coder
.
convertSharedSecretToID
(
ss
));
}
List
<
String
>
topicHandles
=
ESClient
.
getInstance
().
getTopicHandles
(
eids
);
List
<
ESMessage
>
msgsToSend
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
NUM_SIMULATED_DEVICES
;
i
++)
{
...
...
@@ -130,7 +133,7 @@ public class SimulationServerBT {
.
addNewNonce
(
nonces
.
get
((
lowEpoch
*
NUM_SIMULATED_DEVICES
)
+
newIndex
).
toString
())
.
build
();
msgsToSend
.
add
(
new
ESMessage
(
epochLinkMessage
.
toSendMessageText
(
sses
.
get
(
oldIndex
).
getBytes
()),
Coder
.
convertSharedSecretToID
(
sharedSecrets
.
get
(
i
)
).
toString
(),
eids
.
get
(
oldIndex
).
toString
(),
topicHandles
.
get
(
oldIndex
),
true
,
null
,
true
,
-
1
));
}
...
...
@@ -139,7 +142,9 @@ public class SimulationServerBT {
currentEpoch
++;
// heh hack
if
(
currentEpoch
==
NUM_SIMULATED_EPOCHS
)
currentEpoch
--;
},
loop
*
CHANGE_EPOCH_TIME
);
handler
.
postDelayed
(
this
,
CHANGE_EPOCH_TIME
);
}).
start
();
}
},
CHANGE_EPOCH_TIME
);
}
}
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