定时请求在线用户

pull/23/head
taoshihan1991 3 years ago
parent 0ea5292d57
commit 253cfff66c

@ -246,30 +246,6 @@ func SendVisitorNotice(c *gin.Context) {
"msg": "ok",
})
}
func SendCloseMessage(c *gin.Context) {
visitorId := c.Query("visitor_id")
if visitorId == "" {
c.JSON(200, gin.H{
"code": 400,
"msg": "visitor_id不能为空",
})
return
}
msg := TypeMessage{
Type: "close",
Data: visitorId,
}
str, _ := json.Marshal(msg)
for _, visitor := range clientList {
if visitorId == visitor.id {
visitor.conn.WriteMessage(websocket.TextMessage, str)
}
}
c.JSON(200, gin.H{
"code": 200,
"msg": "ok",
})
}
func SendCloseMessageV2(c *gin.Context) {
visitorId := c.Query("visitor_id")
if visitorId == "" {

@ -35,8 +35,6 @@ func InitApiRouter(engine *gin.Engine) {
engine.GET("/message_notice", controller.SendVisitorNotice)
//发送单条消息
engine.POST("/message", middleware.Ipblack, controller.SendMessage)
//发送关闭消息
engine.GET("/message_close", controller.SendCloseMessage)
//上传文件
engine.POST("/uploadimg", middleware.Ipblack, controller.UploadImg)
//上传文件

@ -72,7 +72,10 @@ var app=new Vue({
if(_this.socket!=null){
_this.socket.send(JSON.stringify(mes));
}
},5000)
},20000)
setInterval(function(){
_this.getOnlineVisitors();
},600000);
},
//初始化websocket
initConn() {
@ -429,6 +432,9 @@ var app=new Vue({
//处理tab切换
handleTabClick(tab, event){
let _this=this;
if(tab.name=="first"){
this.getOnlineVisitors();
}
if(tab.name=="second"){
this.getVisitorPage(1);
}

Loading…
Cancel
Save