forked from feross/p2p-graph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
91 lines (75 loc) · 1.79 KB
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<html>
<head>
<title>p2p-graph example</title>
<style>
.torrent-graph {
width: 50%;
height: 100%;
}
</style>
</head>
<body>
<h2>p2p-graph example</h2>
<div class="torrent-graph"></div>
<script type="text/javascript" src="./p2p-graph.min.js"></script>
<script>
let graph = new window.P2PGraph('.torrent-graph')
graph.add({
id: 'You',
me: true,
name: 'You'
})
graph.add({
id: 'Thing1',
me: false,
name: '192.168.1.20'
})
graph.add({
id: 'Thing2',
me: false,
name: '192.168.1.44'
})
setTimeout(() => {
graph.connect('You', 'Thing1')
}, 1000)
setTimeout(() => {
graph.rate('You', 'Thing1', 150 * 1000) // 150 KB/s
}, 2000)
setTimeout(() => {
graph.rate('You', 'Thing1', 500 * 1000) // 500 KB/s
}, 3000)
setTimeout(() => {
graph.rate('You', 'Thing1', 2500 * 1000) // 2.5 MB/s
}, 4000)
setTimeout(() => {
graph.rate('You', 'Thing1', 5000 * 1000) // 5 MB/s
}, 5000)
setTimeout(() => {
graph.rate('You', 'Thing1', 2500 * 1000) // 2.5 MB/s
}, 6000)
setTimeout(() => {
graph.rate('You', 'Thing1', 1000 * 1000) // 1 MB/s
}, 7000)
setTimeout(() => {
console.log('TODO: choke() - set opacity to 0.5')
graph.choke('You', 'Thing1')
}, 8000)
setTimeout(() => {
console.log('TODO: unchoke() - get back to default link opacity')
graph.unchoke('You', 'Thing1')
}, 9000)
setTimeout(() => {
graph.disconnect('You', 'Thing1')
}, 10000)
setTimeout(() => {
graph.remove('Thing1')
}, 11000)
setTimeout(() => {
graph.seed('Thing2', true)
}, 12000)
setTimeout(() => {
graph.seed('Thing2', false)
}, 13000)
</script>
</body>
</html>