增加获取长连接引擎 + 获取server配置方法
This commit is contained in:
parent
e1061bc921
commit
bb34744411
33
construct.go
33
construct.go
@ -42,6 +42,24 @@ type Server struct {
|
||||
conf *config.WSServerConfig // 配置
|
||||
}
|
||||
|
||||
// GetConfig 获取service实例配置
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:36 2024/7/22
|
||||
func (s *Server) GetConfig() *config.WSServerConfig {
|
||||
return s.conf
|
||||
}
|
||||
|
||||
// GetMelody 获取websocket实例
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:37 2024/7/22
|
||||
func (s *Server) GetMelody() *melody.Melody {
|
||||
return s.wsServer
|
||||
}
|
||||
|
||||
var (
|
||||
// ginRouterTable 表
|
||||
ginRouterTable map[int]*gin.Engine
|
||||
@ -94,6 +112,21 @@ func NewWebsocketServe(finishHook func(), wsInstanceList ...abstract.IWebsocket)
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetWsServer 获取ws Server
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:36 2024/7/22
|
||||
func GetWsServer(port int, serverFlag string) (*Server, error) {
|
||||
if _, exist := wsServerTable[port]; !exist {
|
||||
return nil, errors.New(fmt.Sprintf("%v : port is not listen", port))
|
||||
}
|
||||
if _, exist := wsServerTable[port][serverFlag]; !exist {
|
||||
return nil, errors.New(fmt.Sprintf("server flag %v on port %v is not found", serverFlag, port))
|
||||
}
|
||||
return wsServerTable[port][serverFlag], nil
|
||||
}
|
||||
|
||||
// 初始化server
|
||||
func initServer(wsInstance abstract.IWebsocket) {
|
||||
// 初始化ws server
|
||||
|
Loading…
Reference in New Issue
Block a user