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

Support WebRTC communication #126

Merged
merged 1 commit into from
May 8, 2024
Merged

Support WebRTC communication #126

merged 1 commit into from
May 8, 2024

Conversation

billfort
Copy link
Contributor

@billfort billfort commented May 6, 2024

  1. Support WebRTC communication in browser environment;
  2. WebSocket is reserved;
  3. Both WebRTC and WebSocket are compatible;

Signed-off-by: billfort <fxbao@hotmail.com>
this.dc.send(data);
}

constructor(stunServerAddr){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend we support multiple stun server for reliability

@@ -91,6 +100,8 @@ export default class Client {
rpcServerAddr?: string,
tls?: boolean,
worker?: boolean | () => Worker | Promise<Worker>,
stunServerAddr?: string,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend we support multiple stun server for reliability

@@ -8,6 +8,8 @@ export const defaultOptions = {
encrypt: true,
rpcServerAddr: 'https://mainnet-rpc-node-0001.nkn.org/mainnet/api/wallet',
worker: false,
stunServerAddr: 'stun:stun.l.google.com:19302',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend we use all 3 by default:

[
"stun:stun.l.google.com:19302",
"stun:stun.cloudflare.com:3478",
"stun:stunserver.stunprotocol.org:3478",
]

<script src="../dist/nkn.js"></script>
<body>
<h1>WebRTC example</h1>
<button onclick="startClients()">Start WebRTC Clients, Alic and Bob</button>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: Alice

@yilunzhang yilunzhang merged commit 5960235 into nknorg:master May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants