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