2023-01-02 13:52:05 -06:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<head>
|
|
|
|
<title>Forum Network test</title>
|
|
|
|
<link type="text/css" rel="stylesheet" href="/index.css" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="forum-network"></div>
|
|
|
|
</body>
|
|
|
|
<script type="module">
|
|
|
|
import { Box } from "/classes/box.js";
|
|
|
|
import { Scene } from "/classes/scene.js";
|
|
|
|
import { PostContent } from "/classes/post.js";
|
2023-01-03 12:00:12 -06:00
|
|
|
import { Expert } from "/classes/expert.js";
|
2023-01-02 13:52:05 -06:00
|
|
|
import { ForumNode } from "/classes/forum-node.js";
|
|
|
|
import { ForumNetwork } from "/classes/forum-network.js";
|
2023-01-03 01:26:55 -06:00
|
|
|
import { CryptoUtil } from "/classes/crypto.js";
|
2023-01-02 13:52:05 -06:00
|
|
|
import { delay } from "/util.js";
|
|
|
|
|
|
|
|
const rootElement = document.getElementById("forum-network");
|
|
|
|
const rootBox = new Box("rootBox", rootElement).flex();
|
|
|
|
|
|
|
|
window.scene = new Scene("Forum Network test", rootBox).log(
|
|
|
|
"sequenceDiagram"
|
|
|
|
);
|
|
|
|
|
2023-01-03 12:00:12 -06:00
|
|
|
window.author1 = await new Expert("author1", window.scene).initialize();
|
|
|
|
window.author2 = await new Expert("author2", window.scene).initialize();
|
2023-01-02 13:52:05 -06:00
|
|
|
|
|
|
|
window.forumNetwork = new ForumNetwork();
|
|
|
|
|
|
|
|
window.forumNode1 = await new ForumNode("node1", window.scene).initialize(
|
|
|
|
window.forumNetwork
|
|
|
|
);
|
|
|
|
window.forumNode2 = await new ForumNode("node2", window.scene).initialize(
|
|
|
|
window.forumNetwork
|
|
|
|
);
|
|
|
|
window.forumNode3 = await new ForumNode("node3", window.scene).initialize(
|
|
|
|
window.forumNetwork
|
|
|
|
);
|
|
|
|
|
|
|
|
const processInterval = setInterval(async () => {
|
|
|
|
await window.forumNode1.processNextMessage();
|
|
|
|
await window.forumNode2.processNextMessage();
|
|
|
|
await window.forumNode3.processNextMessage();
|
|
|
|
|
|
|
|
await window.scene.renderSequenceDiagram();
|
|
|
|
}, 100);
|
|
|
|
|
|
|
|
// const blockchain = new Blockchain();
|
|
|
|
|
|
|
|
window.post1 = new PostContent({ message: "hi" });
|
2023-01-03 01:26:55 -06:00
|
|
|
window.post1.id = CryptoUtil.randomUUID();
|
2023-01-02 13:52:05 -06:00
|
|
|
window.post2 = new PostContent({ message: "hello" }).addCitation(
|
|
|
|
window.post1.id,
|
|
|
|
1.0
|
|
|
|
);
|
|
|
|
|
|
|
|
await delay(1000);
|
2023-01-03 01:26:55 -06:00
|
|
|
await window.author1.submitPostViaNetwork(
|
|
|
|
window.forumNode1,
|
|
|
|
window.post1,
|
|
|
|
50
|
|
|
|
);
|
2023-01-02 13:52:05 -06:00
|
|
|
await delay(1000);
|
2023-01-03 01:26:55 -06:00
|
|
|
await window.author2.submitPostViaNetwork(
|
|
|
|
window.forumNode2,
|
|
|
|
window.post2,
|
|
|
|
100
|
|
|
|
);
|
2023-01-02 13:52:05 -06:00
|
|
|
|
|
|
|
await delay(1000);
|
|
|
|
clearInterval(processInterval);
|
|
|
|
</script>
|