增加心跳

pull/30/head
taoshihan1991 4 years ago
parent 48554f9203
commit 2103cd1f59

@ -136,7 +136,7 @@ func sendPingToClient() {
delete(kefuList, kefuId) delete(kefuList, kefuId)
} }
} }
time.Sleep(5 * time.Second) time.Sleep(15 * time.Second)
} }
}() }()
@ -291,7 +291,15 @@ func singleBroadcaster(){
} }
str, _ := json.Marshal(msg) str, _ := json.Marshal(msg)
conn.WriteMessage(websocket.TextMessage,str) conn.WriteMessage(websocket.TextMessage,str)
//心跳
case "ping":
msg := TypeMessage{
Type: "pong",
} }
str, _ := json.Marshal(msg)
conn.WriteMessage(websocket.TextMessage,str)
}
} }
} }

@ -57,7 +57,7 @@ func main() {
//设置mysql //设置mysql
engine.GET("/setting_mysql", tmpl.PageSettingMysql) engine.GET("/setting_mysql", tmpl.PageSettingMysql)
//角色列表 //角色列表
engine.GET("/roles", controller.GetRoleList) engine.GET("/roles",middleware.JwtApiMiddleware, controller.GetRoleList)
engine.GET("/roles_list", tmpl.PageRoleList) engine.GET("/roles_list", tmpl.PageRoleList)
//网页部署 //网页部署
@ -82,7 +82,7 @@ func main() {
//文档服务 //文档服务
docs.SwaggerInfo.Title = "GO-FLY接口文档" docs.SwaggerInfo.Title = "GO-FLY接口文档"
docs.SwaggerInfo.Description = "go-fly即时通讯web客服管理系统 , 测试账户:kefu2 测试密码:123 类型:kefu" docs.SwaggerInfo.Description = "go-fly即时通讯web客服管理系统 , 测试账户:kefu2 测试密码:123 类型:kefu"
docs.SwaggerInfo.Version = "0.0.6" docs.SwaggerInfo.Version = "0.0.7"
//docs.SwaggerInfo.Host = "127.0.0.1:"+port //docs.SwaggerInfo.Host = "127.0.0.1:"+port
docs.SwaggerInfo.Host = "gofly.sopans.com" docs.SwaggerInfo.Host = "gofly.sopans.com"
docs.SwaggerInfo.BasePath = "/" docs.SwaggerInfo.BasePath = "/"

@ -2,6 +2,8 @@ package models
type Role struct{ type Role struct{
Id string `json:"role_id"` Id string `json:"role_id"`
Name string `json:"role_name"` Name string `json:"role_name"`
Method string `json:"method"`
Path string `json:"path"`
} }
func FindRoles()[]Role{ func FindRoles()[]Role{
var roles []Role var roles []Role

@ -201,6 +201,18 @@
mes.data = this.kfConfig; mes.data = this.kfConfig;
this.socket.send(JSON.stringify(mes)); this.socket.send(JSON.stringify(mes));
}, },
//心跳
ping(){
let _this=this;
let mes = {}
mes.type = "ping";
mes.data = "";
setInterval(function () {
if(_this.socket!=null){
_this.socket.send(JSON.stringify(mes));
}
},5000)
},
//初始化websocket //初始化websocket
initConn() { initConn() {
let socket = new ReconnectingWebSocket(this.server);//创建Socket实例 let socket = new ReconnectingWebSocket(this.server);//创建Socket实例
@ -487,6 +499,8 @@
}, },
created: function () { created: function () {
this.getKefuInfo(); this.getKefuInfo();
//心跳
this.ping();
} }
}) })

@ -319,6 +319,18 @@
$(".chatBox").css("max-height",$(window).height()); $(".chatBox").css("max-height",$(window).height());
}); });
}, },
//心跳
ping(){
let _this=this;
let mes = {}
mes.type = "ping";
mes.data = "";
setInterval(function () {
if(_this.socket!=null){
_this.socket.send(JSON.stringify(mes));
}
},5000);
},
}, },
created: function () { created: function () {
@ -330,6 +342,8 @@
this.scrollBottom(); this.scrollBottom();
//获取欢迎 //获取欢迎
this.getNotice(); this.getNotice();
//心跳
this.ping();
} }
}) })

@ -2,7 +2,7 @@
<el-menu <el-menu
default-active="3" default-active="3"
mode="horizontal"> mode="horizontal">
<el-menu-item class="mainLogo" v-on:click="openUrl('/login')">GO-FLY<span class="version">V0.0.6</span></el-menu-item> <el-menu-item class="mainLogo" v-on:click="openUrl('/login')">GO-FLY<span class="version">V0.0.7</span></el-menu-item>
<el-menu-item style="display:none" index="2" v-on:click="openIframeUrl('/list')">邮箱<el-badge class="mark" :value="mailTotal" style="margin-bottom: 20px;"/> <el-menu-item style="display:none" index="2" v-on:click="openIframeUrl('/list')">邮箱<el-badge class="mark" :value="mailTotal" style="margin-bottom: 20px;"/>
</el-menu-item> </el-menu-item>
<el-menu-item index="3" v-on:click="openIframeUrl('/chat_main')">聊天</el-menu-item> <el-menu-item index="3" v-on:click="openIframeUrl('/chat_main')">聊天</el-menu-item>

@ -7,7 +7,7 @@
</template> </template>
<el-menu-item-group> <el-menu-item-group>
<el-menu-item style="display:none" index="1-1" v-on:click="">智能回复</el-menu-item> <el-menu-item style="display:none" index="1-1" v-on:click="">智能回复</el-menu-item>
<el-menu-item index="1-2" v-on:click="openUrl('/setting_kefu_list')">客服管理</el-menu-item>
</el-menu-item-group> </el-menu-item-group>
</el-submenu> </el-submenu>
<el-submenu index="3"> <el-submenu index="3">
@ -16,8 +16,8 @@
<span>权限设置</span> <span>权限设置</span>
</template> </template>
<el-menu-item-group> <el-menu-item-group>
<el-menu-item index="1-2" v-on:click="openUrl('/setting_kefu_list')">用户管理</el-menu-item>
<el-menu-item index="3-1" v-on:click="openUrl('/roles_list')">角色管理</el-menu-item> <el-menu-item index="3-1" v-on:click="openUrl('/roles_list')">角色管理</el-menu-item>
<el-menu-item index="3-2" v-on:click="">结点管理</el-menu-item>
</el-menu-item-group> </el-menu-item-group>
</el-submenu> </el-submenu>
<el-submenu index="2"> <el-submenu index="2">

@ -16,6 +16,10 @@
prop="role_name" prop="role_name"
label="角色名称"> label="角色名称">
</el-table-column> </el-table-column>
<el-table-column
prop="method"
label="允许方法">
</el-table-column>
<el-table-column <el-table-column
prop="id" prop="id"
label="操作"> label="操作">

Loading…
Cancel
Save