Skip to content

Commit

Permalink
format webrtc example html
Browse files Browse the repository at this point in the history
Signed-off-by: Yilun <zyl.skysniper@gmail.com>
  • Loading branch information
yilunzhang committed May 23, 2024
1 parent 3747040 commit efb8794
Showing 1 changed file with 11 additions and 12 deletions.
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

0 comments on commit efb8794

Please sign in to comment.