Skip to content

Commit

Permalink
Update janus-gateway/video-room with keepalive
Browse files Browse the repository at this point in the history
Example wasn't sending keep-alives, causing Janus to eventually
end the session even if we weren't done sending
  • Loading branch information
feixiao authored and Sean-Der committed Mar 7, 2019
1 parent 66a2883 commit 83dbac2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion janus-gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This example demonstrates how to stream to a Janus video-room using pion-WebRTC
run `main.go` in `github.com/pions/webrtc/examples/janus-gateway/video-room`

OSX
```sh
```sh
brew install pkg-config
https://gstreamer.freedesktop.org/data/pkg/osx/

Expand Down
11 changes: 11 additions & 0 deletions janus-gateway/video-room/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"math/rand"
"time"

janus "github.com/notedit/janus-go"
"github.com/pions/webrtc"
Expand Down Expand Up @@ -99,6 +100,16 @@ func main() {
panic(err)
}

go func() {
for {
if _, keepAliveErr := session.KeepAlive(); err != nil {
panic(keepAliveErr)
}

time.Sleep(5 * time.Second)
}
}()

go watchHandle(handle)

_, err = handle.Message(map[string]interface{}{
Expand Down

0 comments on commit 83dbac2

Please sign in to comment.