实时视频返回版本2
This commit is contained in:
parent
a10d4add52
commit
3477c7fad4
|
|
@ -243,7 +243,7 @@ func subscribeAndHandleMessagesV2(ws *websocket.Conn, device_id int) {
|
||||||
defer pubsub.Close()
|
defer pubsub.Close()
|
||||||
defer ws.Close()
|
defer ws.Close()
|
||||||
ch := pubsub.Channel()
|
ch := pubsub.Channel()
|
||||||
var ticker *time.Ticker
|
var ticker *time.Ticker // 定时器, 用于发送心跳包, 防止连接断开,每秒发送一次
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case msg, _ := <-ch:
|
case msg, _ := <-ch:
|
||||||
|
|
@ -288,7 +288,7 @@ func subscribeAndHandleMessagesV2(ws *websocket.Conn, device_id int) {
|
||||||
end:
|
end:
|
||||||
// 查看是否还有其他连接,没有则设置 is_play 为 0
|
// 查看是否还有其他连接,没有则设置 is_play 为 0
|
||||||
if worker.IsContainKey(online_conn_key) == false {
|
if worker.IsContainKey(online_conn_key) == false {
|
||||||
worker.SetRedisWithExpire(strconv.Itoa(device_id)+"_is_play", "0", time.Minute*5)
|
worker.SetRedisWithExpire(strconv.Itoa(device_id)+"_is_play", "1", time.Minute*5)
|
||||||
fmt.Println("device_id:", device_id, " has set is_play to 0")
|
fmt.Println("device_id:", device_id, " has set is_play to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue