Skip to content

Conversation

@Sundenis
Copy link
Contributor

This PR adds a new simple -datachannel example to help newcomers understand how to create and test a basic WebRTC DataChannel using Go and a static HTML page (demo.html).

  • Includes main.go for signaling and WebRTC setup.
  • Includes demo.html to test sending/receiving messages.
  • Tested locally and works with the provided signaling server.

@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.69%. Comparing base (8f7e057) to head (2c80f4a).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3252   +/-   ##
=======================================
  Coverage   82.68%   82.69%           
=======================================
  Files          80       80           
  Lines       11196    11196           
=======================================
+ Hits         9257     9258    +1     
- Misses       1514     1516    +2     
+ Partials      425      422    -3     
Flag Coverage Δ
go 82.69% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ValorZard
Copy link

Hm, what's the difference between this and https://github.com/pion/webrtc/tree/master/examples/data-channels ?

@philipch07
Copy link
Contributor

Hm, what's the difference between this and https://github.com/pion/webrtc/tree/master/examples/data-channels ?

The proposed simple-datachannels automatically performs the handshake which hides the handshake which the user would otherwise have to manually perform. I think I updated that example as this one was being written, but I'm not opposed to this being added to show how the handshake can be automated, although maybe this one can have more comments in the code to distinguish itself from the original datachannels example. Just a suggestion, but unsure if there's more to this PR atm.

@ValorZard
Copy link

@philipch07 I think that we need some sort of either example or tutorial showing how to setup a signaling server. It's probably the one things I've struggled with when it comes to WebRTC. Granted, we now have the WHIP/WHEP standard, but that doesn't really apply to datachannel applications.

It's why in the https://github.com/pion/example-webrtc-applications/tree/master/ebiten-game example, I included a sample signaling server I wrote for the game (though I don't think the code in it is very good)

@JoeTurki
Copy link
Member

@philipch07 @ValorZard I feel like this example solves another problem of providing an easy to use example for datachannels for new users. WHIP and WHEP would be cool but datachannels aren't standard too. I think we can add as much examples as we can to make things easier.
For me I think we should merge this.
What do you think?

@philipch07
Copy link
Contributor

@philipch07 I think that we need some sort of either example or tutorial showing how to setup a signaling server. It's probably the one things I've struggled with when it comes to WebRTC.

I'll see if I can take a look into learning about the signaling server if an example is needed for it.

I think we can add as much examples as we can to make things easier.

That's fair, it is a bit of a simpler example for datachannels which the name implies.

I did have an issue with the example: I followed the instructions as I checked out the branch and ran it in VSC connected to WSL. When I opened the page in Firefox it wasn't connecting to the channel, but when I used the "simple browser" inside VSC it was fine. I'm what was causing that issue, since every time I opened the page in Firefox it was showing the ICE candidates in my terminal but it would never connect.

@JoeTurki
Copy link
Member

JoeTurki commented Oct 22, 2025

@philipch07 It just needs to gather and send the ICE candidates, which is what i was going to do before merging it and fix the lint, I think the talk here is about the idea of adding a simple / just work. I think we should merge @Sundenis example is a good idea.

What do you think?

@philipch07
Copy link
Contributor

Oops yeah, sorry I was thinking a little out of scope. This pr sounds good to me!

@JoeTurki
Copy link
Member

@ValorZard Are you okay with merging this after some fixes?

@ValorZard
Copy link

@JoeTurki yeah sure, I'm just more so thinking about like, maybe adding some sort of example for signaling servers specifically in a later PR maybe

@JoeTurki
Copy link
Member

@ValorZard That will be cool btw no pressure but if you can move your whep-like example from being a draft we should merge it.

@JoeTurki
Copy link
Member

@Sundenis hello I fixed the lint issues, and the ICE issue. Merging this now.

@JoeTurki JoeTurki force-pushed the add-simple-datachannel-example branch from 9a22b74 to 2c80f4a Compare October 23, 2025 06:35
@JoeTurki
Copy link
Member

Also i renamed the example directory to data-channels-simple so it's sortable with other examples.

@JoeTurki JoeTurki merged commit 919c686 into pion:master Oct 23, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants