Files
contracts/ws.go
T
what 8b122816a1 重构: 各类型 Controller 接口精简,配合 framework-v2 internal/handler 收拢公共实现
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 里的公共默认实现,只保留接口定义。
2026-07-22 09:14:57 +08:00

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
}