-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
74 lines (61 loc) · 1.77 KB
/
index.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
<html>
<!-- npm install simple-peer -->
<head>
<title>RainbowDash's web app</title>
<script src="browser/bundle.js"></script>
</head>
<body>
<style>
#outgoing {
width: 600px;
word-wrap: break-word;
white-space: normal;
}
</style>
<div id="root">
</div>
<!-- <form>
<textarea id="incoming">Hello</textarea>
<button id="submitButton" type="submit">submit</button>
</form>
<pre id="outgoing"></pre> -->
<!-- <script src="./client.js"></script> -->
<!-- <script src="simplepeer.min.js"></script> -->
<!-- <script>
const options = {
serverUrl: 'http://localhost:8081',
simplePeerOptions: {
initiator: location.hash === '#1',
trickle: false,
wrtc: wrtc
}
};
const spw = new SimplePeerWrapper(options);
spw.connect();
const p = new SimplePeer({
initiator: location.hash === '#1',
trickle: false
})
spw.on('error', err => console.log('error', err))
spw.on('signal', data => {
console.log('SIGNAL', JSON.stringify(data))
document.querySelector('#outgoing').textContent = JSON.stringify(data)
})
document.querySelector('form').addEventListener('submit', ev => {
ev.preventDefault()
spw.signal(JSON.parse(document.querySelector('#incoming').value))
})
spw.on('connect', () => {
console.log('CONNECT')
p.send('whatever' + Math.random())
})
spw.on('data', data => {
console.log('data: ' + data)
})
</script>
<script> src="client.js"</script>
<div id="corn">
<img src="/images/html5.gif" alt="HTML5 Icon" style="width:128px;height:128px;">
</div>
</body>
</html>