-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1738e69
commit 5112e95
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title></title> | ||
<link rel="stylesheet" href="../style.css" /> | ||
</head> | ||
<body> | ||
<h1>PEER-UNAVAILABLE</h1> | ||
<div id="messages"></div> | ||
<div id="error-message"></div> | ||
<script src="/dist/peerjs.js"></script> | ||
<script type="application/javascript"> | ||
/** | ||
* @type {typeof import("../..").Peer} | ||
*/ | ||
const Peer = window.peerjs.Peer; | ||
|
||
const connectionErrors = document.getElementById("messages"); | ||
const peerErrors = document.getElementById("error-message"); | ||
|
||
const not_existing_peer = crypto | ||
.getRandomValues(new Uint8Array(16)) | ||
.join(""); | ||
|
||
const peer = new Peer(); | ||
peer | ||
.once( | ||
"error", | ||
(error) => void (peerErrors.textContent += JSON.stringify(error)), | ||
) | ||
.once("open", (id) => { | ||
const connection = peer.connect(not_existing_peer); | ||
connection.once( | ||
"error", | ||
(error) => | ||
void (connectionErrors.textContent += JSON.stringify(error)), | ||
); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters