fix
This commit is contained in:
parent
88112bc2d0
commit
99f17f86ec
14
construct.go
14
construct.go
@ -21,8 +21,6 @@ import (
|
|||||||
|
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
|
|
||||||
"github.com/go-developer/websocket/storage"
|
|
||||||
|
|
||||||
"github.com/go-developer/websocket/context"
|
"github.com/go-developer/websocket/context"
|
||||||
|
|
||||||
"gopkg.in/olahol/melody.v1"
|
"gopkg.in/olahol/melody.v1"
|
||||||
@ -140,8 +138,8 @@ func NewWebsocketServe(wsInstanceList ...abstract.IWebsocket) error {
|
|||||||
ctx := ctxInterface.(*context.WSContext)
|
ctx := ctxInterface.(*context.WSContext)
|
||||||
ctx.Session = session
|
ctx.Session = session
|
||||||
if err := wsInstance.Connect(ctx); nil == err {
|
if err := wsInstance.Connect(ctx); nil == err {
|
||||||
if ginRouterTable[wsInstance.GetServerPort()].conf.StoreConnection && nil != storage.Connection {
|
if ginRouterTable[wsInstance.GetServerPort()].conf.StoreConnection && nil != ginRouterTable[wsInstance.GetServerPort()].conf.ConnectionManager {
|
||||||
storage.Connection.Store(ctx)
|
ginRouterTable[wsInstance.GetServerPort()].conf.ConnectionManager.Store(ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -157,10 +155,10 @@ func NewWebsocketServe(wsInstanceList ...abstract.IWebsocket) error {
|
|||||||
ctxInterface, _ := session.Get("ws_context")
|
ctxInterface, _ := session.Get("ws_context")
|
||||||
ctx := ctxInterface.(*context.WSContext)
|
ctx := ctxInterface.(*context.WSContext)
|
||||||
defer func() {
|
defer func() {
|
||||||
if !ginRouterTable[wsInstance.GetServerPort()].conf.StoreConnection || nil == storage.Connection {
|
if !ginRouterTable[wsInstance.GetServerPort()].conf.StoreConnection || nil == ginRouterTable[wsInstance.GetServerPort()].conf.ConnectionManager {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
storage.Connection.Del(ctx)
|
ginRouterTable[wsInstance.GetServerPort()].conf.ConnectionManager.Del(ctx)
|
||||||
}()
|
}()
|
||||||
return wsInstance.Close(ctx, i, s)
|
return wsInstance.Close(ctx, i, s)
|
||||||
})
|
})
|
||||||
@ -169,10 +167,10 @@ func NewWebsocketServe(wsInstanceList ...abstract.IWebsocket) error {
|
|||||||
ctxInterface, _ := session.Get("ws_context")
|
ctxInterface, _ := session.Get("ws_context")
|
||||||
ctx := ctxInterface.(*context.WSContext)
|
ctx := ctxInterface.(*context.WSContext)
|
||||||
defer func() {
|
defer func() {
|
||||||
if nil == storage.Connection {
|
if nil == ginRouterTable[wsInstance.GetServerPort()].conf.ConnectionManager {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
storage.Connection.Del(ctx)
|
ginRouterTable[wsInstance.GetServerPort()].conf.ConnectionManager.Del(ctx)
|
||||||
}()
|
}()
|
||||||
wsInstance.Disconnect(ctx)
|
wsInstance.Disconnect(ctx)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user