Compare commits
2 Commits
2040232735
...
ea963f4076
| Author | SHA1 | Date |
|---|---|---|
|
|
ea963f4076 | |
|
|
6bdaeaf017 |
|
|
@ -11,6 +11,7 @@ import (
|
|||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
|
@ -194,11 +195,13 @@ func subscribeAndHandleMessagesV3(ws *websocket.Conn, deviceId int) {
|
|||
count := 0
|
||||
//定时器,发送计数器
|
||||
tCount := 0
|
||||
var buf []byte
|
||||
//计算帧率
|
||||
for {
|
||||
//从service获取当前帧
|
||||
buf, c := service.GetDeviceCurrentFrameV4(deviceId, count)
|
||||
newBuf, c := service.GetDeviceCurrentFrameV4(deviceId, count)
|
||||
if c != count {
|
||||
buf = newBuf
|
||||
count = c
|
||||
err2 := ws.WriteMessage(websocket.BinaryMessage, buf)
|
||||
if err2 != nil {
|
||||
|
|
@ -220,7 +223,6 @@ func subscribeAndHandleMessagesV3(ws *websocket.Conn, deviceId int) {
|
|||
}
|
||||
}
|
||||
}
|
||||
buf = nil
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
tCount++
|
||||
}
|
||||
|
|
@ -230,4 +232,7 @@ func subscribeAndHandleMessagesV3(ws *websocket.Conn, deviceId int) {
|
|||
worker.SetRedisWithExpire(strconv.Itoa(deviceId)+"_is_play", "1", time.Minute*5)
|
||||
log.Printf("device_id: %d has set is_play to 0", deviceId)
|
||||
}
|
||||
|
||||
//垃圾回收
|
||||
runtime.GC()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue