diff --git a/rpc/context.go b/rpc/context.go index e6519dec..30860073 100644 --- a/rpc/context.go +++ b/rpc/context.go @@ -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) } diff --git a/rpc/context_test.go b/rpc/context_test.go index 4e9e1c94..b3948d86 100644 --- a/rpc/context_test.go +++ b/rpc/context_test.go @@ -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) diff --git a/rpc/wrtc_server_channel.go b/rpc/wrtc_server_channel.go index 086f7c25..05a327b4 100644 --- a/rpc/wrtc_server_channel.go +++ b/rpc/wrtc_server_channel.go @@ -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.