可配置是否存储连接

This commit is contained in:
2021-04-17 23:14:54 +08:00
parent 563c334757
commit 3548b434d0
2 changed files with 16 additions and 2 deletions

View File

@ -137,7 +137,7 @@ func NewWebsocketServe(wsInstanceList ...abstract.IWebsocket) error {
ctx := ctxInterface.(*context.WSContext)
ctx.Session = session
if err := wsInstance.Connect(ctx); nil == err {
if nil != storage.Connection {
if ginRouterTable[wsInstance.GetServerPort()].conf.StoreConnection && nil != storage.Connection {
storage.Connection.Store(ctx)
}
}
@ -154,7 +154,7 @@ func NewWebsocketServe(wsInstanceList ...abstract.IWebsocket) error {
ctxInterface, _ := session.Get("ws_context")
ctx := ctxInterface.(*context.WSContext)
defer func() {
if nil == storage.Connection {
if !ginRouterTable[wsInstance.GetServerPort()].conf.StoreConnection || nil == storage.Connection {
return
}
storage.Connection.Del(ctx)