This commit is contained in:
Wyle.Gong-巩文昕
2025-04-23 11:21:08 +08:00
parent fc643727f3
commit 7a1aae1e2f
135 changed files with 221483 additions and 1 deletions
+42
View File
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Simple</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
crossorigin="anonymous">
</head>
<body>
<!-- a place to record messages -->
<div id="messages" class="container"></div>
<!-- load a script -->
<script type="module">
import { connect } from '../nats.js'
// add an entry to the document
function addEntry(s) {
const p = document.createElement("pre");
p.appendChild(document.createTextNode(s));
document.getElementById("messages").appendChild(p);
}
const init = async function () {
try {
// create a connection to a wss server
const nc = await connect({ servers: 'wss://localhost:9222' });
addEntry('connected!');
await nc.flush();
addEntry('did a round-trip to the server');
// close the connection
await nc.close();
addEntry('closed the connection');
} catch(err) {
addEntry(`error connecting - did you setup a wss server? ${err}`);
console.error(err)
}
}
init();
</script>
</body>
</html>