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

RSDK-9896: Allow anyone to attach PeerConnections to contexts. #411

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions rpc/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func contextDialer(ctx context.Context) Dialer {
return dialer.(Dialer)
}

// contextWithPeerConnection attaches a peer connection to the given context.
func contextWithPeerConnection(ctx context.Context, pc *webrtc.PeerConnection) context.Context {
// ContextWithPeerConnection attaches a peer connection to the given context.
func ContextWithPeerConnection(ctx context.Context, pc *webrtc.PeerConnection) context.Context {
return context.WithValue(ctx, ctxKeyPeerConnection, pc)
}

Expand Down
2 changes: 1 addition & 1 deletion rpc/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestContextDialer(t *testing.T) {
func TestContextPeerConnection(t *testing.T) {
ctx := context.Background()
var pc webrtc.PeerConnection
ctx = contextWithPeerConnection(ctx, &pc)
ctx = ContextWithPeerConnection(ctx, &pc)
_, ok := ContextPeerConnection(context.Background())
test.That(t, ok, test.ShouldBeFalse)
pc2, ok := ContextPeerConnection(ctx)
Expand Down
2 changes: 1 addition & 1 deletion rpc/wrtc_server_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (ch *webrtcServerChannel) onChannelMessage(msg webrtc.DataChannelMessage) {
} else {
handlerCtx, cancelCtx = context.WithTimeout(handlerCtx, timeout)
}
handlerCtx = contextWithPeerConnection(handlerCtx, ch.peerConn)
handlerCtx = ContextWithPeerConnection(handlerCtx, ch.peerConn)

// TODO(GOUT-11): Handle auth; right now we assume successful auth to the signaler
// implies that auth should be allowed here, which is not 100% true.
Expand Down
Loading