diff --git a/api/version1/customerform/form.go b/api/version1/customerform/form.go index 36f027c..0a49c74 100644 --- a/api/version1/customerform/form.go +++ b/api/version1/customerform/form.go @@ -1068,7 +1068,7 @@ func (a *ApiMethod) EditCustomerFormInfo(c *gin.Context) { cureeTime := time.Now().Unix() mainData := publicmethod.MapOut[string]() mainData["`name`"] = formJsonCont.Form.FormName - mainData["`classify`"] = requestData.Classify + mainData["`classify`"] = requestData.Types mainData["`edit_time`"] = cureeTime if formJsonCont.Config.ImageUrl != "" { mainData["`icon`"] = formJsonCont.Config.ImageUrl diff --git a/api/version1/webStocetmsg/server.go b/api/version1/webStocetmsg/server.go deleted file mode 100644 index 595bb3b..0000000 --- a/api/version1/webStocetmsg/server.go +++ /dev/null @@ -1,116 +0,0 @@ -package webstocetmsg - -import ( - "fmt" - "sync" - "time" - - "github.com/golang-module/carbon" -) - -var GatewayClients, GatewayUser, GatewayGroup sync.Map - -/** - * @description: 客户端心跳检测,超时即断开连接(主要是为了降低服务端承载压力) - * @param {string} clientID - * @return {*} - */ - -func clientHeartbeatCheck(clientID string) { - - for { - - time.Sleep(5 * time.Second) - - clientInterface, exists := GatewayClients.Load(clientID) - - if !exists { - - break - } - - client, _ := clientInterface.(*WebSocketClientBase) - - if (carbon.Now().Timestamp() - client.LastHeartbeat) > int64(HeartbeatTime) { - - fmt.Println("Client", clientID, "heartbeat timeout") - - client.Conn.Close() - GatewayClients.Delete(clientID) - break - } - } -} - -/** - * @description: 客户端断线时自动踢出Uid绑定列表 - * @param {string} clientID - * @param {string} uid - * @return {*} - */ -func clientUnBindUid(clientID string, uid string) { - - value, ok := GatewayUser.Load(uid) - - if ok { - - users := value.(*WebSocketUserBase) - - for k, v := range users.ClientID { - - if v == clientID { - - users.ClientID = append(users.ClientID[:k], users.ClientID[k+1:]...) - } - } - - if len(users.ClientID) == 0 { - - GatewayUser.Delete(uid) - } - - } -} - -/** - * @description: 客户端断线时自动踢出已加入的群组 - * @param {string} clientID - * @return {*} - */ -func clientLeaveGroup(clientID string) { - // 使用 Load 方法获取值 - value, ok := GatewayClients.Load(clientID) - if !ok { - // 如果没有找到对应的值,处理相应的逻辑 - return - } - - client := value.(*WebSocketClientBase) - - // 遍历 JoinGroup - for _, v := range client.JoinGroup { - // 使用 Load 方法获取值 - groupValue, groupOK := GatewayGroup.Load(v) - if !groupOK { - // 如果没有找到对应的值,处理相应的逻辑 - continue - } - - group := groupValue.(*WebSocketGroupBase) - - // 在群组中找到对应的 clientID,并删除 - for j, id := range group.ClientID { - if id == clientID { - copy(group.ClientID[j:], group.ClientID[j+1:]) - group.ClientID = group.ClientID[:len(group.ClientID)-1] - - // 如果群组中没有成员了,删除群组 - if len(group.ClientID) == 0 { - GatewayGroup.Delete(v) - } - - break - } - } - } -}