Make new path for signalling v1.5 support. (#4180)

* Make new path for signalling v1.5 support.

To be able to support newer clients to interact with older servers, move
signalling v1.5 to new path (`/rtc1`). On the new path, `join_request`
is required and single peer connection is used.

With the existing path `/rtc`, single peer connection is still supported
if `join_request` is used.

Newer clients connecting to old server should follow
1. Try new path WebSocket
2. If that fails, try new path validate at `/rtc1/validate`.
3. If the above gets a 404 which will happen with older server, revert
   back to old path and signalling 1.0.

Open to suggestions on path name.

* test on both paths

* change path from /rtc1 -> /rtc/v1

* test all rtc service path combinations
This commit is contained in:
Raja Subramanian
2025-12-20 01:02:22 +05:30
committed by GitHub
parent 32cd0370c7
commit cd99fec2e7
10 changed files with 249 additions and 160 deletions
+51 -7
View File
@@ -203,33 +203,77 @@ func createMultiNodeServer(nodeID string, port uint32) *service.LivekitServer {
return s
}
type testRTCServicePath int
const (
testRTCServicePathv0 testRTCServicePath = iota
testRTCServicePathv0SinglePeerConnection
testRTCServicePathv1
)
func (t testRTCServicePath) String() string {
switch t {
case testRTCServicePathv0:
return "v0"
case testRTCServicePathv0SinglePeerConnection:
return "v0-single-peer-connection"
case testRTCServicePathv1:
return "v1"
default:
return fmt.Sprintf("unknown: %d", t)
}
}
var testRTCServicePaths = []testRTCServicePath{
testRTCServicePathv0,
testRTCServicePathv0SinglePeerConnection,
testRTCServicePathv1,
}
func testRTCServicePathToTestClientOptions(testRTCServicePath testRTCServicePath, opts *testclient.Options) {
if opts == nil {
return
}
switch testRTCServicePath {
case testRTCServicePathv0:
opts.RTCServicePath = "/rtc"
case testRTCServicePathv0SinglePeerConnection:
opts.RTCServicePath = "/rtc"
opts.UseJoinRequestQueryParam = true
case testRTCServicePathv1:
opts.RTCServicePath = "/rtc/v1"
opts.UseJoinRequestQueryParam = true
default:
opts.RTCServicePath = "/rtc"
}
}
// creates a client and runs against server
func createRTCClient(name string, port int, useSinglePeerConnection bool, opts *testclient.Options) *testclient.RTCClient {
func createRTCClient(name string, port int, testRTCServicePath testRTCServicePath, opts *testclient.Options) *testclient.RTCClient {
var customizer func(token *auth.AccessToken, grants *auth.VideoGrant)
if opts != nil {
customizer = opts.TokenCustomizer
}
token := joinToken(testRoom, name, customizer)
return createRTCClientWithToken(token, port, useSinglePeerConnection, opts)
return createRTCClientWithToken(token, port, testRTCServicePath, opts)
}
// creates a client and runs against server
func createRTCClientWithToken(token string, port int, useSinglePeerConnection bool, opts *testclient.Options) *testclient.RTCClient {
func createRTCClientWithToken(token string, port int, testRTCServicePath testRTCServicePath, opts *testclient.Options) *testclient.RTCClient {
if opts == nil {
opts = &testclient.Options{
AutoSubscribe: true,
}
}
if useSinglePeerConnection {
opts.UseJoinRequestQueryParam = true
}
testRTCServicePathToTestClientOptions(testRTCServicePath, opts)
ws, err := testclient.NewWebSocketConn(fmt.Sprintf("ws://localhost:%d", port), token, opts)
if err != nil {
panic(err)
}
c, err := testclient.NewRTCClient(ws, useSinglePeerConnection, opts)
c, err := testclient.NewRTCClient(ws, opts.UseJoinRequestQueryParam, opts)
if err != nil {
panic(err)
}