app.go/condflow.go/cron.go/event_stream.go/executor.go/gobridge.go/grpc.go/job.go/mcp.go/mqtt.go/res_virtual_table.go/ws.go/controller.go/support/service.go 精简掉搬到 framework-v2 internal/handler 里的公共默认实现,只保留接口定义。
52 lines
959 B
Go
52 lines
959 B
Go
package contracts
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"git.fsdpf.net/go/req"
|
|
"github.com/gorilla/websocket"
|
|
)
|
|
|
|
type WsClientGroup string
|
|
type WsClientID uint
|
|
|
|
const DefaultWsClientGroup WsClientGroup = "__DEFAULT__"
|
|
|
|
type WsClient interface {
|
|
req.User
|
|
Socket() *websocket.Conn
|
|
WsClientID() WsClientID
|
|
WsClientGroup() WsClientGroup
|
|
WsClientManage() WsClientManage
|
|
Lock()
|
|
Unlock()
|
|
}
|
|
|
|
type WsClientManage interface {
|
|
Register(WsClient) bool
|
|
Unregister(WsClient)
|
|
GetClients(func(WsClient) bool) []WsClient
|
|
}
|
|
|
|
type WsChannelManage interface {
|
|
Channel(string) WsClientManage
|
|
}
|
|
|
|
type WsController interface {
|
|
Controller
|
|
// 获取请求信息
|
|
Request() *http.Request
|
|
// 请求处理
|
|
Execute(req.GlobalParams) error
|
|
// 获取用户信息
|
|
User() req.User
|
|
// 路由信息
|
|
Route() req.Route
|
|
// 获取 Ws 客户端
|
|
Client() WsClient
|
|
// 获取 Ws 标识
|
|
ClientID(req.GlobalParams) WsClientID
|
|
// 获取 Ws 分组
|
|
ClientGroup(req.GlobalParams) WsClientGroup
|
|
}
|