Commit fa5f3f03 authored by Lily Tsai's avatar Lily Tsai

handler still not working...

parent 0cb312d6
......@@ -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.postDelayed(() -> {
Log.d(TAG, "Handler loop!");
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<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);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment