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