Skip to content

Commit

Permalink
RSDK-9896: Allow anyone to attach PeerConnections to contexts. (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgottlieb authored Feb 3, 2025
1 parent cf6c56e commit a03938d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
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

0 comments on commit a03938d

Please sign in to comment.