mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-09 10:43:44 +08:00
在进行 socket 连接前先关闭之前连接。实现新建会话功能。
This commit is contained in:
@@ -290,6 +290,17 @@ func (s *Server) RemoveUserHandle(c *gin.Context) {
|
||||
|
||||
// GetUserListHandle 获取用户列表
|
||||
func (s *Server) GetUserListHandle(c *gin.Context) {
|
||||
username := c.PostForm("username")
|
||||
if username != "" {
|
||||
user, err := GetUser(username)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, types.BizVo{Code: types.Failed, Message: "User not exists"})
|
||||
} else {
|
||||
c.JSON(http.StatusOK, types.BizVo{Code: types.Success, Message: types.OkMsg, Data: user})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, types.BizVo{Code: types.Success, Message: types.OkMsg, Data: GetUsers()})
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ func (s *Server) Run(webRoot embed.FS, path string, debug bool) {
|
||||
for {
|
||||
for key, ctx := range s.ChatContexts {
|
||||
// 清理超过 60min 没有更新,则表示为过期会话
|
||||
if time.Now().Unix()-ctx.LastAccessTime > int64(s.Config.Chat.ChatContextExpireTime) {
|
||||
if time.Now().Unix()-ctx.LastAccessTime >= int64(s.Config.Chat.ChatContextExpireTime) {
|
||||
logger.Infof("清理会话上下文: %s", key)
|
||||
delete(s.ChatContexts, key)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user