Documentation
¶
Index ¶
Constants ¶
View Source
const ConfigKey = "websocket"
ConfigKey for this repo
Variables ¶
View Source
var Factory *tao.BaseFactory[ws.Upgrader]
Factory is the global factory instance for managing ws.Upgrader
View Source
var W = &Config{}
W is the global config instance for tao-websocket
Functions ¶
func GetUpgrader ¶
GetUpgrader returns the websocket upgrader instance by name
func NewWebSocket ¶
NewWebSocket creates a new WebSocket upgrader for factory pattern
Types ¶
type Config ¶
type Config struct {
tao.BaseMultiConfig[InstanceConfig]
RunAfters []string `json:"run_after,omitempty" yaml:"run_after,omitempty"`
}
Config 总配置,实现 tao.MultiConfig 接口
type Connection ¶
Connection of websocket
func New ¶
func New(w http.ResponseWriter, r *http.Request, options ...func(*Connection) error) (*Connection, error)
New constructor of websocket connection with default upgrader
func NewWith ¶
func NewWith(w http.ResponseWriter, r *http.Request, name string, options ...func(*Connection) error) (*Connection, error)
NewWith constructor of websocket connection with specified upgrader instance name
type InstanceConfig ¶
type InstanceConfig struct {
CheckOrigin *bool `json:"check_origin" yaml:"check_origin"`
ReadBufferSize int `json:"read_buffer_size" yaml:"read_buffer_size"`
WriteBufferSize int `json:"write_buffer_size" yaml:"write_buffer_size"`
Subprotocols []string `json:"subprotocols" yaml:"subprotocols"`
}
InstanceConfig 单实例配置
Click to show internal directories.
Click to hide internal directories.