Documentation ¶
Overview ¶
websocket handler built on top of guerilla/websocket
Index ¶
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 is a middleman between the websocket connection and the hub.
type DefaultDialer ¶
type DefaultDialer struct {
// contains filtered or unexported fields
}
func NewDialer ¶
func NewDialer(addr string) *DefaultDialer
func (*DefaultDialer) Addr ¶
func (dialer *DefaultDialer) Addr() string
func (*DefaultDialer) Send ¶
func (dialer *DefaultDialer) Send(data any) error
Send message to all websocket clients
type HubOption ¶
type HubOption func(*WebsocketHandler)
type WebsocketHandler ¶
type WebsocketHandler struct {
// contains filtered or unexported fields
}
WebsocketHandler maintains the set of active clients and broadcasts messages to the clients.
WebsocketHandler implements http.Handler interface and can be used directly in your http routes.
hub, quit := ws.NewHandler() defer quit() go hub.Run() http.Handle("/", http.FileServer(http.Dir("public"))) http.Handle("/ws", hub) log.Fatal(http.ListenAndServe(":8080", nil))
func NewHandler ¶
func NewHandler(options ...HubOption) (handler *WebsocketHandler, quit func())
func (*WebsocketHandler) Run ¶
func (h *WebsocketHandler) Run()
Infinite loop that runs the hub indefinately. Run this is a go routine.
func (*WebsocketHandler) ServeHTTP ¶
func (hub *WebsocketHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
Http handler
Click to show internal directories.
Click to hide internal directories.