Skip to content

Commit 83dbac2

Browse files
feixiaoSean-Der
authored andcommitted
Update janus-gateway/video-room with keepalive
Example wasn't sending keep-alives, causing Janus to eventually end the session even if we weren't done sending
1 parent 66a2883 commit 83dbac2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

janus-gateway/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This example demonstrates how to stream to a Janus video-room using pion-WebRTC
2727
run `main.go` in `github.com/pions/webrtc/examples/janus-gateway/video-room`
2828

2929
OSX
30-
```sh
30+
```sh
3131
brew install pkg-config
3232
https://gstreamer.freedesktop.org/data/pkg/osx/
3333

janus-gateway/video-room/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"log"
66
"math/rand"
7+
"time"
78

89
janus "github.com/notedit/janus-go"
910
"github.com/pions/webrtc"
@@ -99,6 +100,16 @@ func main() {
99100
panic(err)
100101
}
101102

103+
go func() {
104+
for {
105+
if _, keepAliveErr := session.KeepAlive(); err != nil {
106+
panic(keepAliveErr)
107+
}
108+
109+
time.Sleep(5 * time.Second)
110+
}
111+
}()
112+
102113
go watchHandle(handle)
103114

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

0 commit comments

Comments
 (0)