livekit / server-sdk-go

Client and server SDK for Golang
Apache License 2.0
214 stars 96 forks source link

Not being able to use signalclient after migrate from v1 to v2 #534

Closed UladzimirTrehubenka closed 2 weeks ago

UladzimirTrehubenka commented 2 months ago

Observed during migrate from v1.1.8 to v2.2.1:

import lksdk "github.com/livekit/server-sdk-go"
// v1.1.8 code
client := lksdk.NewSignalClient()
res, err := client.Join(url, token, &lksdk.ConnectParams{AutoSubscribe: true})

in #392 we can see that

func (c *SignalClient) Join(urlPrefix string, token string, params *ConnectParams) (*livekit.JoinResponse, error)

became

func (c *SignalClient) Join(urlPrefix string, token string, params connectParams) (*livekit.JoinResponse, error)

So for now function Join() cannot be used outside (only inside the SDK itself), actually this is broken design - how exported method would use private structure?!

davidzhao commented 2 months ago

we don't recommend using SignalClient by itself outside of the SDK itself. what is your use case?

UladzimirTrehubenka commented 2 months ago

Custom app server: mobile -> app server -> livekit instead direct mobile -> livekit

UladzimirTrehubenka commented 2 months ago

Is it possible to add something like

func (c *SignalClient) JoinWithAutoSubscribe(urlPrefix string, token string, autoSubscribe bool) (*livekit.JoinResponse, error) {
    params := connectParams{AutoSubscribe: autoSubscribe}
    return c.Join(urlPrefix, token, params)
}

This is how we are using v2 for now with patch vendor folder during build.

davidzhao commented 1 month ago

in that case, I think it's ok to make connectParams public. would you like to open a PR renaming it to SignalClientConnectParams ?

UladzimirTrehubenka commented 1 month ago

Created https://github.com/livekit/server-sdk-go/pull/540

UladzimirTrehubenka commented 1 month ago

@davidzhao could you please add reviewers?

UladzimirTrehubenka commented 4 weeks ago

@davidzhao any progress?