支持从 gin router注册长连接地址

This commit is contained in:
白茶清欢 2024-07-22 17:43:22 +08:00
parent 726f6b5911
commit e1061bc921
1 changed files with 20 additions and 0 deletions

View File

@ -55,6 +55,26 @@ var (
sigChan = make(chan int, 1)
)
// NewWebsocketServeWithGinRouter ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 17:41 2024/7/22
func NewWebsocketServeWithGinRouter(ginPort int, ginRouter *gin.Engine, wsInstanceList ...abstract.IWebsocket) error {
if len(wsInstanceList) == 0 {
return errors.WithStack(errors.New("register websocket server list is empty"))
}
ginRouterTable = map[int]*gin.Engine{
ginPort: ginRouter,
}
wsServerTable = make(map[int]map[string]*Server)
commandTable = make(map[string]map[string]abstract.ICommand)
for _, wsInstance := range wsInstanceList {
initServer(wsInstance)
}
return nil
}
// NewWebsocketServe 启动websocket服务
//
// Author : go_developer@163.com<白茶清欢>