Compare commits
No commits in common. "7c78231d91d192bf11067a1fec83179c0307345f" and "22442eb82800b82c3aa5465f25928bdfd24eb87e" have entirely different histories.
7c78231d91
...
22442eb828
|
|
@ -178,30 +178,19 @@ 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))
|
||||||
var res3 []byte
|
|
||||||
var msg proto.Message
|
|
||||||
if res2 != "" {
|
if res2 != "" {
|
||||||
|
var msg proto.Message
|
||||||
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,7 +3,6 @@ package service
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
"videoplayer/dao"
|
"videoplayer/dao"
|
||||||
"videoplayer/proto"
|
"videoplayer/proto"
|
||||||
)
|
)
|
||||||
|
|
@ -48,11 +47,7 @@ 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