Skip to content

Commit

Permalink
ws ping
Browse files Browse the repository at this point in the history
  • Loading branch information
deepch committed Jul 14, 2022
1 parent 3947209 commit 4937383
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 12 additions & 0 deletions apiHTTPMSE.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,20 @@ func HTTPAPIServerStreamMSE(ws *websocket.Conn) {
}
}()
noVideo := time.NewTimer(10 * time.Second)
pingTicker := time.NewTicker(500 * time.Millisecond)
defer pingTicker.Stop()
for {
select {
case <-pingTicker.C:
ws.PayloadType = websocket.PingFrame
err = ws.SetWriteDeadline(time.Now().Add(3 * time.Second))
if err != nil {
return
}
_, err = ws.Write(nil)
if err != nil {
return
}
case <-controlExit:
requestLogger.WithFields(logrus.Fields{
"call": "controlExit",
Expand Down
1 change: 0 additions & 1 deletion streamCore.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ func StreamServerRunStreamRTMP(streamID string, channelID string, opt *ChannelST
case <-Signals:
return 0, ErrorStreamStopRTSPSignal
case packetAV := <-OutgoingPacketQueue:

if preDur[packetAV.Idx] != 0 {
packetAV.Duration = packetAV.Time - preDur[packetAV.Idx]
}
Expand Down

0 comments on commit 4937383

Please sign in to comment.