Documentation
¶
Index ¶
- type Client
- type ConnectionManager
- func (cm *ConnectionManager) CleanInactiveConnections(inactiveTimeout time.Duration)
- func (cm *ConnectionManager) GetActiveConnections() int
- func (cm *ConnectionManager) GetClient(connectionID string) (*Client, bool)
- func (cm *ConnectionManager) GetClientByCustomerID(customerID uint) (*Client, bool)
- func (cm *ConnectionManager) HandleWebSocket(w http.ResponseWriter, r *http.Request, handlers MessageHandlers)
- func (cm *ConnectionManager) Register(client *Client)
- func (cm *ConnectionManager) Unregister(client *Client)
- type MessageHandlers
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 表示一个WebSocket客户端连接
type ConnectionManager ¶
type ConnectionManager struct {
// contains filtered or unexported fields
}
ConnectionManager 管理所有的WebSocket连接和会话
func NewConnectionManager ¶
func NewConnectionManager(db *gorm.DB) *ConnectionManager
NewConnectionManager 创建新的连接管理器
func (*ConnectionManager) CleanInactiveConnections ¶
func (cm *ConnectionManager) CleanInactiveConnections(inactiveTimeout time.Duration)
CleanInactiveConnections 清理不活跃的连接
func (*ConnectionManager) GetActiveConnections ¶
func (cm *ConnectionManager) GetActiveConnections() int
GetActiveConnections 获取活跃连接数
func (*ConnectionManager) GetClient ¶
func (cm *ConnectionManager) GetClient(connectionID string) (*Client, bool)
GetClient 根据连接ID获取客户端
func (*ConnectionManager) GetClientByCustomerID ¶
func (cm *ConnectionManager) GetClientByCustomerID(customerID uint) (*Client, bool)
GetClientByCustomerID 根据客户ID获取客户端
func (*ConnectionManager) HandleWebSocket ¶
func (cm *ConnectionManager) HandleWebSocket(w http.ResponseWriter, r *http.Request, handlers MessageHandlers)
HandleWebSocket 处理WebSocket连接请求
func (*ConnectionManager) Register ¶
func (cm *ConnectionManager) Register(client *Client)
Register 注册新的客户端连接
func (*ConnectionManager) Unregister ¶
func (cm *ConnectionManager) Unregister(client *Client)
Unregister 注销客户端连接
type MessageHandlers ¶
MessageHandlers 定义消息处理器
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) SetupRoutes ¶
func (s *Server) SetupRoutes(db *gorm.DB, handlers MessageHandlers, cm *ConnectionManager)
SetupRoutes 配置所有路由
Click to show internal directories.
Click to hide internal directories.