-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: log info to console when polyfill-ed; add test/* pages (#3)
also, created a raw websocket endpoint on deno: <img width="1218" alt="image" src="https://user-images.githubusercontent.com/65603/225317842-92d4cabd-fd33-48ca-abb7-963167323d04.png">
- Loading branch information
1 parent
7cf7e7f
commit b5407f4
Showing
5 changed files
with
122 additions
and
95 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
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 |
---|---|---|
@@ -1,38 +1,51 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
<script src="../dist/index.global.js"></script> | ||
</head> | ||
<body> | ||
<div> | ||
Open in firefox | ||
</div> | ||
<script> | ||
(async () => { | ||
var uid = "ws-" + (Math.random() + 1).toString(36).substring(7); | ||
const url = `https://lo.yomo.dev:8443/v1?publickey=kmJAUnCtkWbkNnhXYtZAGEJzGDGpFo1e1vkp6cm&id=${uid}`; | ||
const transport = new WebTransport(url); | ||
|
||
// Optionally, set up functions to respond to | ||
// the connection closing: | ||
transport.closed | ||
.then(() => { | ||
console.log(`The HTTP/3 connection to ${url} closed gracefully.`); | ||
}) | ||
.catch((error) => { | ||
console.error( | ||
`The HTTP/3 connection to ${url} closed due to `, | ||
error | ||
); | ||
}); | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
<script src="../dist/index.global.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div> | ||
Please open this file in firefox or Safari after `pnpm run build` | ||
</div> | ||
<script> | ||
let transport | ||
(async () => { | ||
var uid = "ws-" + (Math.random() + 1).toString(36).substring(7); | ||
const url = `https://wsss.deno.dev/?id=${uid}`; | ||
transport = new WebTransport(url); | ||
|
||
// Optionally, set up functions to respond to | ||
// the connection closing: | ||
transport.closed | ||
.then(() => { | ||
console.log(`The HTTP/3 connection to ${url} closed gracefully.`); | ||
}) | ||
.catch((error) => { | ||
console.error( | ||
`The HTTP/3 connection to ${url} closed due to `, | ||
error | ||
); | ||
}); | ||
|
||
// Once .ready fulfills, the connection can be used. | ||
await transport.ready; | ||
|
||
console.log("connected") | ||
})(); | ||
|
||
// setTimeout(() => { | ||
// transport.close({ | ||
// closeCode: 017, | ||
// reason: 'CloseButtonPressed' | ||
// }) | ||
// }, 3000) | ||
</script> | ||
</body> | ||
|
||
// Once .ready fulfills, the connection can be used. | ||
await transport.ready; | ||
})(); | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,59 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
<script src="../dist/index.global.js"></script> | ||
</head> | ||
<body> | ||
<div> | ||
Open in firefox | ||
</div> | ||
<script> | ||
(async () => { | ||
var uid = "ws-" + (Math.random() + 1).toString(36).substring(7); | ||
const url = `https://lo.yomo.dev:8443/v1?publickey=kmJAUnCtkWbkNnhXYtZAGEJzGDGpFo1e1vkp6cm&id=${uid}`; | ||
const transport = new WebTransport(url); | ||
|
||
// Optionally, set up functions to respond to | ||
// the connection closing: | ||
transport.closed | ||
.then(() => { | ||
console.log(`The HTTP/3 connection to ${url} closed gracefully.`); | ||
}) | ||
.catch((error) => { | ||
console.error( | ||
`The HTTP/3 connection to ${url} closed due to `, | ||
error | ||
); | ||
}); | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
<script src="../dist/index.global.js"></script> | ||
</head> | ||
|
||
// Once .ready fulfills, the connection can be used. | ||
await transport.ready; | ||
<body> | ||
<div> | ||
Open in firefox | ||
</div> | ||
<script> | ||
(async () => { | ||
var uid = "ws-" + (Math.random() + 1).toString(36).substring(7); | ||
const url = `https://wsss.deno.dev/?id=${uid}`; | ||
const transport = new WebTransport(url); | ||
|
||
// Send two datagrams to the server. | ||
const writer = transport.datagrams.writable.getWriter(); | ||
const data1 = new Uint8Array([65, 66, 67]); | ||
const data2 = new Uint8Array([68, 69, 70]); | ||
writer.write(data1); | ||
writer.write(data2); | ||
// Optionally, set up functions to respond to | ||
// the connection closing: | ||
transport.closed | ||
.then(() => { | ||
console.log(`The HTTP/3 connection to ${url} closed gracefully.`); | ||
}) | ||
.catch((error) => { | ||
console.error( | ||
`The HTTP/3 connection to ${url} closed due to `, | ||
error | ||
); | ||
}); | ||
|
||
// Read datagrams from the server. | ||
const reader = transport.datagrams.readable.getReader(); | ||
while (true) { | ||
const { value, done } = await reader.read(); | ||
if (done) { | ||
break; | ||
} | ||
// value is a Uint8Array. | ||
console.log(value); | ||
// Once .ready fulfills, the connection can be used. | ||
await transport.ready; | ||
|
||
// Send two datagrams to the server. | ||
const writer = transport.datagrams.writable.getWriter(); | ||
const data1 = new Uint8Array([65, 66, 67]); | ||
const data2 = new Uint8Array([68, 69, 70, 71]); | ||
writer.write(data1); | ||
setTimeout(() => {writer.write(data2)}, 1e3) | ||
|
||
// Read datagrams from the server. | ||
const reader = transport.datagrams.readable.getReader(); | ||
while (true) { | ||
const {value, done} = await reader.read(); | ||
if (done) { | ||
break; | ||
} | ||
})(); | ||
</script> | ||
</body> | ||
// value is a Uint8Array. | ||
console.log(value); | ||
} | ||
})(); | ||
</script> | ||
</body> | ||
|
||
</html> |