[feat] 重新梳理 ws

This commit is contained in:
2024-05-10 21:18:21 +08:00
parent 6d3b2267b9
commit 584571513c
2 changed files with 63 additions and 41 deletions
-41
View File
@@ -40,28 +40,11 @@ type HttpController interface {
AuthDB() req.ResAuthDB
}
type WsController interface {
HttpController
// 请求处理
ExecuteWS(req.GlobalParams) error
// 获取 Ws 客户端
WsClient() WsClient
// 获取 Ws 标识
WsClientId(req.GlobalParams) WsClientID
// 获取 Ws 分组
WsClientGroup(req.GlobalParams) WsClientGroup
}
type HttpHandleController struct {
Controller
request *http.Request
}
type WsHandleController struct {
HttpController
ws WsClient
}
func (this HttpHandleController) Request() *http.Request {
return this.request
}
@@ -86,33 +69,9 @@ func (HttpHandleController) AuthDB() req.ResAuthDB {
return req.ResAuthOn
}
func (WsHandleController) ExecuteWS(params req.GlobalParams) error {
return nil
}
func (this WsHandleController) WsClient() WsClient {
return this.ws
}
func (WsHandleController) WsClientId(req.GlobalParams) WsClientID {
wsClientID++
return wsClientID
}
func (WsHandleController) WsClientGroup(req.GlobalParams) WsClientGroup {
return defaultWsClientGroup
}
func NewHttpController(container *do.Injector, request *http.Request) HttpController {
return &HttpHandleController{
Controller: &BaseController{container},
request: request,
}
}
func NewWsController(ws WsClient, ctr HttpController) WsController {
return &WsHandleController{
HttpController: ctr,
ws: ws,
}
}