Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
EncounterBasedCommunication
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
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
Hide 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,37 +108,43 @@ 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
.
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
);
handler
.
postDelayed
(
new
Runnable
()
{
public
void
run
()
{
new
Thread
(()
->
{
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
<
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
++)
{
for
(
int
j
=
currentEpoch
+
1
;
j
>
lowEpoch
+
1
;
j
--)
{
int
oldIndex
=
(
j
-
1
-
lowEpoch
)
*
NUM_SIMULATED_DEVICES
+
i
;
int
newIndex
=
(
j
-
lowEpoch
)
*
NUM_SIMULATED_DEVICES
+
i
;
if
(
topicHandles
.
get
(
oldIndex
)
==
null
||
topicHandles
.
get
(
oldIndex
).
compareTo
(
""
)
==
0
)
{
continue
;
List
<
ESMessage
>
msgsToSend
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
NUM_SIMULATED_DEVICES
;
i
++)
{
for
(
int
j
=
currentEpoch
+
1
;
j
>
lowEpoch
+
1
;
j
--)
{
int
oldIndex
=
(
j
-
1
-
lowEpoch
)
*
NUM_SIMULATED_DEVICES
+
i
;
int
newIndex
=
(
j
-
lowEpoch
)
*
NUM_SIMULATED_DEVICES
+
i
;
if
(
topicHandles
.
get
(
oldIndex
)
==
null
||
topicHandles
.
get
(
oldIndex
).
compareTo
(
""
)
==
0
)
{
continue
;
}
EpochLinkMessage
epochLinkMessage
=
new
EpochLinkMessage
.
EpochLinkMessageBuilder
()
.
addOldNonce
(
nonces
.
get
((
lowEpoch
*
NUM_SIMULATED_DEVICES
)
+
oldIndex
).
toString
())
.
addNewNonce
(
nonces
.
get
((
lowEpoch
*
NUM_SIMULATED_DEVICES
)
+
newIndex
).
toString
())
.
build
();
msgsToSend
.
add
(
new
ESMessage
(
epochLinkMessage
.
toSendMessageText
(
sses
.
get
(
oldIndex
).
getBytes
()),
eids
.
get
(
oldIndex
).
toString
(),
topicHandles
.
get
(
oldIndex
),
true
,
null
,
true
,
-
1
));
}
EpochLinkMessage
epochLinkMessage
=
new
EpochLinkMessage
.
EpochLinkMessageBuilder
()
.
addOldNonce
(
nonces
.
get
((
lowEpoch
*
NUM_SIMULATED_DEVICES
)
+
oldIndex
).
toString
())
.
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
(),
topicHandles
.
get
(
oldIndex
),
true
,
null
,
true
,
-
1
));
}
}
ESClient
.
getInstance
().
sendMsgs
(
msgsToSend
);
currentEpoch
++;
// heh hack
if
(
currentEpoch
==
NUM_SIMULATED_EPOCHS
)
currentEpoch
--;
},
loop
*
CHANGE_EPOCH_TIME
);
}
ESClient
.
getInstance
().
sendMsgs
(
msgsToSend
);
currentEpoch
++;
// heh hack
if
(
currentEpoch
==
NUM_SIMULATED_EPOCHS
)
currentEpoch
--;
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