Skip to content

Commit

Permalink
update SDK version, improve logging (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidzhao authored Dec 6, 2021
1 parent 73f03a9 commit ff31ae5
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 37 deletions.
19 changes: 17 additions & 2 deletions cmd/livekit-cli/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import (
"syscall"
"time"

"github.com/livekit/protocol/logger"
livekit "github.com/livekit/protocol/proto"
lksdk "github.com/livekit/server-sdk-go"
"github.com/pion/webrtc/v3"
"github.com/urfave/cli/v2"
)

Expand Down Expand Up @@ -48,12 +51,24 @@ func joinRoom(c *cli.Context) error {
return err
}

fmt.Println("connected to room", room.Name)
logger.Infow("connected to room", room.Name)

done := make(chan os.Signal, 1)
signal.Notify(done, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
room.Callback.OnDataReceived = func(data []byte, rp *lksdk.RemoteParticipant) {

logger.Infow("received data", "bytes", len(data))
}
room.Callback.OnConnectionQualityChanged = func(update *livekit.ConnectionQualityInfo, p lksdk.Participant) {
logger.Infow("connection quality changed", "participant", p.Identity(), "quality", update.Quality)
}
room.Callback.OnRoomMetadataChanged = func(metadata string) {
logger.Infow("room metadata changed", "metadata", metadata)
}
room.Callback.OnTrackSubscribed = func(track *webrtc.TrackRemote, pub *lksdk.RemoteTrackPublication, participant *lksdk.RemoteParticipant) {
logger.Infow("track subscribed", "kind", pub.Kind(), "trackID", pub.SID(), "source", pub.Source())
}
room.Callback.OnTrackUnsubscribed = func(track *webrtc.TrackRemote, pub *lksdk.RemoteTrackPublication, participant *lksdk.RemoteParticipant) {
logger.Infow("track unsubscribed", "kind", pub.Kind(), "trackID", pub.SID(), "source", pub.Source())
}
files := c.StringSlice("publish")
for _, f := range files {
Expand Down
5 changes: 5 additions & 0 deletions cmd/livekit-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package main

import (
"fmt"
"log"
"os"

"github.com/go-logr/stdr"
"github.com/livekit/protocol/logger"
"github.com/urfave/cli/v2"

livekit_cli "github.com/livekit/livekit-cli"
Expand All @@ -21,6 +24,8 @@ func main() {
Version: livekit_cli.Version,
}

logger.SetLogger(stdr.New(log.Default()), "livekit-cli")

app.Commands = append(app.Commands, TokenCommands...)
app.Commands = append(app.Commands, RoomCommands...)
app.Commands = append(app.Commands, JoinCommands...)
Expand Down
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ go 1.16

require (
github.com/ggwhite/go-masker v1.0.4
github.com/livekit/protocol v0.9.11
github.com/livekit/server-sdk-go v0.7.4
github.com/pion/webrtc/v3 v3.0.32
github.com/go-logr/stdr v1.2.0
github.com/livekit/protocol v0.10.4
github.com/livekit/server-sdk-go v0.8.0
github.com/pion/webrtc/v3 v3.1.11
github.com/stretchr/testify v1.7.0
github.com/urfave/cli/v2 v2.3.0
google.golang.org/protobuf v1.27.1
Expand Down
Loading

0 comments on commit ff31ae5

Please sign in to comment.