Ability to set name on Participant (#293)
This commit is contained in:
@@ -14,7 +14,7 @@ require (
|
|||||||
github.com/google/wire v0.5.0
|
github.com/google/wire v0.5.0
|
||||||
github.com/gorilla/websocket v1.4.2
|
github.com/gorilla/websocket v1.4.2
|
||||||
github.com/hashicorp/golang-lru v0.5.4
|
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/magefile/mage v1.11.0
|
||||||
github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0
|
github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0
|
||||||
github.com/mitchellh/go-homedir v1.1.0
|
github.com/mitchellh/go-homedir v1.1.0
|
||||||
|
|||||||
@@ -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/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 h1:pr15YQyvhiSX/qPxncFtqk+v4xLEpOZObbsY/mKrcvA=
|
||||||
github.com/lithammer/shortuuid/v3 v3.0.6/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts=
|
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.5 h1:1wArim3zmGgfvawXAs7Mo6Vu+xkW6z4q2EL2Gbr0A/c=
|
||||||
github.com/livekit/protocol v0.11.4/go.mod h1:YoHW9YbWbPnuVsgwBB4hAINKT+V68jmfh9zXBSSn6Wg=
|
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 h1:C/55Ywp9BpgVVclD3lRnSYCwXTYxmSppIgLeDYlNuls=
|
||||||
github.com/magefile/mage v1.11.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
|
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=
|
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ type MessageSource interface {
|
|||||||
|
|
||||||
type ParticipantInit struct {
|
type ParticipantInit struct {
|
||||||
Identity string
|
Identity string
|
||||||
|
Name string
|
||||||
Metadata string
|
Metadata string
|
||||||
Reconnect bool
|
Reconnect bool
|
||||||
Permission *livekit.ParticipantPermission
|
Permission *livekit.ParticipantPermission
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ func (r *RedisRouter) StartParticipantSignal(ctx context.Context, roomName strin
|
|||||||
RoomName: roomName,
|
RoomName: roomName,
|
||||||
Identity: pi.Identity,
|
Identity: pi.Identity,
|
||||||
Metadata: pi.Metadata,
|
Metadata: pi.Metadata,
|
||||||
|
Name: pi.Name,
|
||||||
// connection id is to allow the RTC node to identify where to route the message back to
|
// connection id is to allow the RTC node to identify where to route the message back to
|
||||||
ConnectionId: connectionID,
|
ConnectionId: connectionID,
|
||||||
Reconnect: pi.Reconnect,
|
Reconnect: pi.Reconnect,
|
||||||
@@ -240,6 +241,7 @@ func (r *RedisRouter) startParticipantRTC(ss *livekit.StartSession, participantK
|
|||||||
pi := ParticipantInit{
|
pi := ParticipantInit{
|
||||||
Identity: ss.Identity,
|
Identity: ss.Identity,
|
||||||
Metadata: ss.Metadata,
|
Metadata: ss.Metadata,
|
||||||
|
Name: ss.Name,
|
||||||
Reconnect: ss.Reconnect,
|
Reconnect: ss.Reconnect,
|
||||||
Permission: ss.Permission,
|
Permission: ss.Permission,
|
||||||
Client: ss.Client,
|
Client: ss.Client,
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ const (
|
|||||||
|
|
||||||
type ParticipantParams struct {
|
type ParticipantParams struct {
|
||||||
Identity string
|
Identity string
|
||||||
|
Name string
|
||||||
SID string
|
SID string
|
||||||
Config *WebRTCConfig
|
Config *WebRTCConfig
|
||||||
Sink routing.MessageSink
|
Sink routing.MessageSink
|
||||||
@@ -226,6 +227,7 @@ func (p *ParticipantImpl) ToProto() *livekit.ParticipantInfo {
|
|||||||
info := &livekit.ParticipantInfo{
|
info := &livekit.ParticipantInfo{
|
||||||
Sid: p.params.SID,
|
Sid: p.params.SID,
|
||||||
Identity: p.params.Identity,
|
Identity: p.params.Identity,
|
||||||
|
Name: p.params.Name,
|
||||||
Metadata: p.metadata,
|
Metadata: p.metadata,
|
||||||
State: p.State(),
|
State: p.State(),
|
||||||
JoinedAt: p.ConnectedAt().Unix(),
|
JoinedAt: p.ConnectedAt().Unix(),
|
||||||
|
|||||||
@@ -230,6 +230,7 @@ func (r *RoomManager) StartSession(ctx context.Context, roomName string, pi rout
|
|||||||
pLogger := rtc.LoggerWithParticipant(room.Logger, pi.Identity, sid)
|
pLogger := rtc.LoggerWithParticipant(room.Logger, pi.Identity, sid)
|
||||||
participant, err = rtc.NewParticipant(rtc.ParticipantParams{
|
participant, err = rtc.NewParticipant(rtc.ParticipantParams{
|
||||||
Identity: pi.Identity,
|
Identity: pi.Identity,
|
||||||
|
Name: pi.Name,
|
||||||
SID: sid,
|
SID: sid,
|
||||||
Config: &rtcConf,
|
Config: &rtcConf,
|
||||||
Sink: responseSink,
|
Sink: responseSink,
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ func (s *RTCService) validate(r *http.Request) (string, routing.ParticipantInit,
|
|||||||
pi := routing.ParticipantInit{
|
pi := routing.ParticipantInit{
|
||||||
Reconnect: boolValue(reconnectParam),
|
Reconnect: boolValue(reconnectParam),
|
||||||
Identity: claims.Identity,
|
Identity: claims.Identity,
|
||||||
|
Name: claims.Name,
|
||||||
AutoSubscribe: true,
|
AutoSubscribe: true,
|
||||||
Metadata: claims.Metadata,
|
Metadata: claims.Metadata,
|
||||||
Hidden: claims.Video.Hidden,
|
Hidden: claims.Video.Hidden,
|
||||||
|
|||||||
@@ -228,7 +228,9 @@ func redisClient() *redis.Client {
|
|||||||
func joinToken(room, name string) string {
|
func joinToken(room, name string) string {
|
||||||
at := auth.NewAccessToken(testApiKey, testApiSecret).
|
at := auth.NewAccessToken(testApiKey, testApiSecret).
|
||||||
AddGrant(&auth.VideoGrant{RoomJoin: true, Room: room}).
|
AddGrant(&auth.VideoGrant{RoomJoin: true, Room: room}).
|
||||||
SetIdentity(name)
|
SetIdentity(name).
|
||||||
|
SetName(name).
|
||||||
|
SetMetadata("metadata" + name)
|
||||||
t, err := at.ToJWT()
|
t, err := at.ToJWT()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -239,7 +241,8 @@ func joinToken(room, name string) string {
|
|||||||
func joinTokenWithGrant(name string, grant *auth.VideoGrant) string {
|
func joinTokenWithGrant(name string, grant *auth.VideoGrant) string {
|
||||||
at := auth.NewAccessToken(testApiKey, testApiSecret).
|
at := auth.NewAccessToken(testApiKey, testApiSecret).
|
||||||
AddGrant(grant).
|
AddGrant(grant).
|
||||||
SetIdentity(name)
|
SetIdentity(name).
|
||||||
|
SetName(name)
|
||||||
t, err := at.ToJWT()
|
t, err := at.ToJWT()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -249,8 +252,7 @@ func joinTokenWithGrant(name string, grant *auth.VideoGrant) string {
|
|||||||
|
|
||||||
func createRoomToken() string {
|
func createRoomToken() string {
|
||||||
at := auth.NewAccessToken(testApiKey, testApiSecret).
|
at := auth.NewAccessToken(testApiKey, testApiSecret).
|
||||||
AddGrant(&auth.VideoGrant{RoomCreate: true}).
|
AddGrant(&auth.VideoGrant{RoomCreate: true})
|
||||||
SetIdentity("testuser")
|
|
||||||
t, err := at.ToJWT()
|
t, err := at.ToJWT()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ func TestMultiNodeRouting(t *testing.T) {
|
|||||||
require.Equal(t, c1.ID(), streamID)
|
require.Equal(t, c1.ID(), streamID)
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
remoteC1 := c2.GetRemoteParticipant(c1.ID())
|
||||||
|
require.Equal(t, "c1", remoteC1.Name)
|
||||||
|
require.Equal(t, "metadatac1", remoteC1.Metadata)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConnectWithoutCreation(t *testing.T) {
|
func TestConnectWithoutCreation(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user