-
-
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
2cba46d
commit bee2bdb
Showing
4 changed files
with
74 additions
and
3 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
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,41 @@ | ||
<!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"> | ||
(async () => { | ||
/** | ||
* @type {typeof import("../../lib/exports.ts").Peer} | ||
*/ | ||
const Peer = window.peerjs.Peer; | ||
|
||
const messages = document.getElementById("messages"); | ||
const errors = document.getElementById("error-message"); | ||
|
||
const not_existing_peer = crypto | ||
.getRandomValues(new Uint8Array(16)) | ||
.join(""); | ||
|
||
try { | ||
const peer = await new Peer(); | ||
await peer.connect(not_existing_peer); | ||
} catch (error) { | ||
if (error.type === "peer-unavailable") { | ||
messages.textContent = "Success: Peer unavailable"; | ||
} else { | ||
errors.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
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