升级connectionID生成规则

This commit is contained in:
白茶清欢 2021-04-18 01:02:17 +08:00
parent 4177c01939
commit 9b9a976663
1 changed files with 4 additions and 3 deletions

View File

@ -45,7 +45,7 @@ func NewContext(ginCtx *gin.Context, flag string, session *melody.Session) *WSCo
d, _ := easymap.NewSegment(128, true)
l, _ := easylock.NewSegment(128)
return &WSContext{
ConnectionID: generateConnectionID(),
ConnectionID: generateConnectionID(flag),
Flag: flag,
GinCtx: ginCtx,
Session: session,
@ -60,8 +60,9 @@ func NewContext(ginCtx *gin.Context, flag string, session *melody.Session) *WSCo
// Author : go_developer@163.com<张德满>
//
// Date : 5:18 下午 2021/4/8
func generateConnectionID() string {
return fmt.Sprintf("%s-%s-%s",
func generateConnectionID(flag string) string {
return fmt.Sprintf("%s-%s-%s-%s",
flag,
strings.ReplaceAll(util.GetHostIP(), ".", ""),
time.Now().Format("20060102150405"),
util.Md5(fmt.Sprintf("%d", time.Now().UnixNano())+util.GenRandomString("", 64)))