Documentation
¶
Index ¶
- func ClientAttributesFunc(...) *func(hub *WebSocketHub, r *http.Request) (ClientAttributes, error)
- func OnConnect(...) *func(hub *WebSocketHub, clientAttributes ClientAttributes, r *http.Request)
- func OnDisconnect(...) *func(hub *WebSocketHub, clientAttributes ClientAttributes, err error)
- func OnError(onErrorFunc func(err error)) *func(err error)
- func SetConfig(_config Config)
- func UpgradeConnection(hub *WebSocketHub, handler *Handler, clientAttributes ClientAttributes, ...) error
- type ClientAttributes
- type ClientMessage
- type Config
- type Handler
- type WebSocketClient
- type WebSocketHub
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientAttributesFunc ¶ added in v0.0.3
func ClientAttributesFunc(clientAttributesFunc func(hub *WebSocketHub, r *http.Request) (ClientAttributes, error)) *func(hub *WebSocketHub, r *http.Request) (ClientAttributes, error)
func OnConnect ¶
func OnConnect(onConnectFunc func(hub *WebSocketHub, clientAttributes ClientAttributes, r *http.Request)) *func(hub *WebSocketHub, clientAttributes ClientAttributes, r *http.Request)
func OnDisconnect ¶ added in v0.0.5
func OnDisconnect(onDisconnectFunc func(hub *WebSocketHub, clientAttributes ClientAttributes, err error)) *func(hub *WebSocketHub, clientAttributes ClientAttributes, err error)
func UpgradeConnection ¶
func UpgradeConnection( hub *WebSocketHub, handler *Handler, clientAttributes ClientAttributes, w http.ResponseWriter, r *http.Request, ) error
Types ¶
type ClientAttributes ¶
type ClientAttributes interface{}
type ClientMessage ¶
type ClientMessage struct {
Message []byte
Client ClientAttributes
}
type Handler ¶
type Handler struct {
UhttpHandler uhttp.Handler
ClientAttributes *func(hub *WebSocketHub, r *http.Request) (ClientAttributes, error)
OnConnect *func(hub *WebSocketHub, clientAttributes ClientAttributes, r *http.Request)
OnDisconnect *func(hub *WebSocketHub, clientAttributes ClientAttributes, err error)
OnError *func(err error)
}
type WebSocketClient ¶
type WebSocketClient struct {
// contains filtered or unexported fields
}
Client is a middleman between the websocket connection and the hub.
type WebSocketHub ¶
type WebSocketHub struct {
// contains filtered or unexported fields
}
func CreateHubAndRunInBackground ¶
func CreateHubAndRunInBackground(messagHandler *chan ClientMessage) *WebSocketHub
func NewWebSocketHub ¶
func NewWebSocketHub(messagHandler *chan ClientMessage) *WebSocketHub
func (*WebSocketHub) Handle ¶
func (h *WebSocketHub) Handle(pattern string, handler *Handler)
func (*WebSocketHub) Run ¶
func (h *WebSocketHub) Run()
func (*WebSocketHub) SendWithFilter ¶
func (h *WebSocketHub) SendWithFilter(filterFunc func(attrs ClientAttributes) bool, message []byte) error
Click to show internal directories.
Click to hide internal directories.