Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format webrtc example html #141

Merged
merged 1 commit into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions examples/webrtc.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>WebRTC example</title>
<script src="../dist/nkn.js"></script>
<style>
p {
font-size: smaller;
}
</style>
</head>
<body>
<h1>WebRTC example</h1>
Expand All @@ -19,10 +14,14 @@ <h1>WebRTC example</h1>
two clients, Alice and Bob.
</p>
<p>
If connect to locak NKN node, please uncomment the line of <b>rpcServerAddr</b> in the code.
If connect to local NKN node, please uncomment the line of
<b>rpcServerAddr</b> in the code.
</p>

<button onclick="startClients()" style="padding: 10px; background-color: green; color: white;">

<button
onclick="startClients()"
style="padding: 10px; background-color: green; color: white"
>
Start WebRTC Clients, Alice and Bob
</button>
<div id="output" style="margin-top: 2rem"></div>
Expand Down Expand Up @@ -57,13 +56,15 @@ <h1>WebRTC example</h1>
});

alice.onConnectFailed(() => {
// will be triggered when the multiclient fails to connect
log("Alice connect failed");
});

if (useMultiClient) {
for (let clientID of Object.keys(alice.clients)) {
alice.clients[clientID].onConnectFailed(() => {
log("Alice client", clientID, "connect failed");
// will be triggered when a single client fails to connect
// log("Alice client", clientID, "connect failed");
});
}
}
Expand All @@ -77,9 +78,7 @@ <h1>WebRTC example</h1>
log("Alice connected");
log("Bob connected");

await new Promise((resolve, reject) =>
setTimeout(resolve, 1000),
);
await new Promise((resolve, reject) => setTimeout(resolve, 1000));

let timeSent = Date.now();

Expand Down