Ability to set name on Participant (#293)

This commit is contained in:
David Zhao
2021-12-28 00:12:04 -08:00
committed by GitHub
parent b747cdb822
commit 3108ef22ad
9 changed files with 20 additions and 7 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ require (
github.com/google/wire v0.5.0
github.com/gorilla/websocket v1.4.2
github.com/hashicorp/golang-lru v0.5.4
github.com/livekit/protocol v0.11.4
github.com/livekit/protocol v0.11.5
github.com/magefile/mage v1.11.0
github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0
github.com/mitchellh/go-homedir v1.1.0
+2 -2
View File
@@ -132,8 +132,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lithammer/shortuuid/v3 v3.0.6 h1:pr15YQyvhiSX/qPxncFtqk+v4xLEpOZObbsY/mKrcvA=
github.com/lithammer/shortuuid/v3 v3.0.6/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts=
github.com/livekit/protocol v0.11.4 h1:p4ZA/OW+Wuc3q48DdeSFUAFaTHmqz62/C/LXM3D0/Z4=
github.com/livekit/protocol v0.11.4/go.mod h1:YoHW9YbWbPnuVsgwBB4hAINKT+V68jmfh9zXBSSn6Wg=
github.com/livekit/protocol v0.11.5 h1:1wArim3zmGgfvawXAs7Mo6Vu+xkW6z4q2EL2Gbr0A/c=
github.com/livekit/protocol v0.11.5/go.mod h1:YoHW9YbWbPnuVsgwBB4hAINKT+V68jmfh9zXBSSn6Wg=
github.com/magefile/mage v1.11.0 h1:C/55Ywp9BpgVVclD3lRnSYCwXTYxmSppIgLeDYlNuls=
github.com/magefile/mage v1.11.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
+1
View File
@@ -28,6 +28,7 @@ type MessageSource interface {
type ParticipantInit struct {
Identity string
Name string
Metadata string
Reconnect bool
Permission *livekit.ParticipantPermission
+2
View File
@@ -151,6 +151,7 @@ func (r *RedisRouter) StartParticipantSignal(ctx context.Context, roomName strin
RoomName: roomName,
Identity: pi.Identity,
Metadata: pi.Metadata,
Name: pi.Name,
// connection id is to allow the RTC node to identify where to route the message back to
ConnectionId: connectionID,
Reconnect: pi.Reconnect,
@@ -240,6 +241,7 @@ func (r *RedisRouter) startParticipantRTC(ss *livekit.StartSession, participantK
pi := ParticipantInit{
Identity: ss.Identity,
Metadata: ss.Metadata,
Name: ss.Name,
Reconnect: ss.Reconnect,
Permission: ss.Permission,
Client: ss.Client,
+2
View File
@@ -37,6 +37,7 @@ const (
type ParticipantParams struct {
Identity string
Name string
SID string
Config *WebRTCConfig
Sink routing.MessageSink
@@ -226,6 +227,7 @@ func (p *ParticipantImpl) ToProto() *livekit.ParticipantInfo {
info := &livekit.ParticipantInfo{
Sid: p.params.SID,
Identity: p.params.Identity,
Name: p.params.Name,
Metadata: p.metadata,
State: p.State(),
JoinedAt: p.ConnectedAt().Unix(),
+1
View File
@@ -230,6 +230,7 @@ func (r *RoomManager) StartSession(ctx context.Context, roomName string, pi rout
pLogger := rtc.LoggerWithParticipant(room.Logger, pi.Identity, sid)
participant, err = rtc.NewParticipant(rtc.ParticipantParams{
Identity: pi.Identity,
Name: pi.Name,
SID: sid,
Config: &rtcConf,
Sink: responseSink,
+1
View File
@@ -100,6 +100,7 @@ func (s *RTCService) validate(r *http.Request) (string, routing.ParticipantInit,
pi := routing.ParticipantInit{
Reconnect: boolValue(reconnectParam),
Identity: claims.Identity,
Name: claims.Name,
AutoSubscribe: true,
Metadata: claims.Metadata,
Hidden: claims.Video.Hidden,
+6 -4
View File
@@ -228,7 +228,9 @@ func redisClient() *redis.Client {
func joinToken(room, name string) string {
at := auth.NewAccessToken(testApiKey, testApiSecret).
AddGrant(&auth.VideoGrant{RoomJoin: true, Room: room}).
SetIdentity(name)
SetIdentity(name).
SetName(name).
SetMetadata("metadata" + name)
t, err := at.ToJWT()
if err != nil {
panic(err)
@@ -239,7 +241,8 @@ func joinToken(room, name string) string {
func joinTokenWithGrant(name string, grant *auth.VideoGrant) string {
at := auth.NewAccessToken(testApiKey, testApiSecret).
AddGrant(grant).
SetIdentity(name)
SetIdentity(name).
SetName(name)
t, err := at.ToJWT()
if err != nil {
panic(err)
@@ -249,8 +252,7 @@ func joinTokenWithGrant(name string, grant *auth.VideoGrant) string {
func createRoomToken() string {
at := auth.NewAccessToken(testApiKey, testApiSecret).
AddGrant(&auth.VideoGrant{RoomCreate: true}).
SetIdentity("testuser")
AddGrant(&auth.VideoGrant{RoomCreate: true})
t, err := at.ToJWT()
if err != nil {
panic(err)
+4
View File
@@ -52,6 +52,10 @@ func TestMultiNodeRouting(t *testing.T) {
require.Equal(t, c1.ID(), streamID)
return true
})
remoteC1 := c2.GetRemoteParticipant(c1.ID())
require.Equal(t, "c1", remoteC1.Name)
require.Equal(t, "metadatac1", remoteC1.Metadata)
}
func TestConnectWithoutCreation(t *testing.T) {