Compare commits
2 Commits
22442eb828
...
7c78231d91
| Author | SHA1 | Date |
|---|---|---|
|
|
7c78231d91 | |
|
|
75a0cb9f3c |
|
|
@ -178,19 +178,30 @@ func SRMessage(c *gin.Context) {
|
||||||
for {
|
for {
|
||||||
if v := clients[ws]; v == true {
|
if v := clients[ws]; v == true {
|
||||||
res2 := worker.PopRedisListLeft(res + "_" + strconv.Itoa(id1))
|
res2 := worker.PopRedisListLeft(res + "_" + strconv.Itoa(id1))
|
||||||
if res2 != "" {
|
var res3 []byte
|
||||||
var msg proto.Message
|
var msg proto.Message
|
||||||
|
if res2 != "" {
|
||||||
msg.Type = "msg"
|
msg.Type = "msg"
|
||||||
msg.Msg = res2
|
msg.Msg = res2
|
||||||
msg.From_user_id = id1
|
msg.From_user_id = id1
|
||||||
msg.Session = res
|
msg.Session = res
|
||||||
res3, _ := json.Marshal(msg)
|
res3, _ = json.Marshal(msg)
|
||||||
|
} else {
|
||||||
|
//若无消息则发送心跳包
|
||||||
|
msg.Type = "check"
|
||||||
|
msg.Msg = "check"
|
||||||
|
msg.From_user_id = -1
|
||||||
|
msg.Session = res
|
||||||
|
res3, _ = json.Marshal(msg)
|
||||||
|
}
|
||||||
err2 := ws.WriteMessage(websocket.TextMessage, res3)
|
err2 := ws.WriteMessage(websocket.TextMessage, res3)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
|
clientsMux.Lock()
|
||||||
|
delete(clients, ws)
|
||||||
|
clientsMux.Unlock()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
time.Sleep(time.Second * 1) // 每1秒查询一次
|
||||||
time.Sleep(time.Second * 1) // 每100毫秒查询一次
|
|
||||||
} else {
|
} else {
|
||||||
clientsMux.Lock()
|
clientsMux.Lock()
|
||||||
delete(clients, ws)
|
delete(clients, ws)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package service
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
"videoplayer/dao"
|
"videoplayer/dao"
|
||||||
"videoplayer/proto"
|
"videoplayer/proto"
|
||||||
)
|
)
|
||||||
|
|
@ -47,7 +48,11 @@ func GetVideoList(auth_id int, start, end, hour string) []dao.Video {
|
||||||
es1 := strings.Split(es[1], ":")
|
es1 := strings.Split(es[1], ":")
|
||||||
end = es[0] + " " + hour + ":" + es1[1] + ":" + es1[2]
|
end = es[0] + " " + hour + ":" + es1[1] + ":" + es1[2]
|
||||||
}
|
}
|
||||||
|
_, err := time.Parse("2006-01-02 15:04:05", start)
|
||||||
|
_, err2 := time.Parse("2006-01-02 15:04:05", end)
|
||||||
|
if err != nil || err2 != nil {
|
||||||
|
return []dao.Video{}
|
||||||
|
}
|
||||||
return dao.FindVideoListByTime(auth_id, start, end)
|
return dao.FindVideoListByTime(auth_id, start, end)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue