websocket

package
v0.0.0-...-01a19e3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Upgrader = websocket.Upgrader{
	CheckOrigin: func(r *http.Request) bool { return true },
}

Functions

This section is empty.

Types

type Client

type Client struct {
	ID string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(conn *websocket.Conn) *Client

func (*Client) Listen

func (c *Client) Listen(ctx context.Context) error

func (*Client) OnDisconnect

func (c *Client) OnDisconnect(f func())

func (*Client) OnEvent

func (c *Client) OnEvent(f func(eventType string, data interface{}))

func (*Client) Send

func (c *Client) Send(eventType string, data interface{}) error

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer() *Server

func (*Server) AddClient

func (s *Server) AddClient(c *Client)

func (*Server) Broadcast

func (s *Server) Broadcast(eventType string, data interface{}) error

func (*Server) OnConnect

func (s *Server) OnConnect(f func(*Client))

func (*Server) RemoveClient

func (s *Server) RemoveClient(c *Client)

func (*Server) Serve

func (s *Server) Serve(w http.ResponseWriter, r *http.Request) error

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL