websocket

package
v3.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultDialer = websocket.DefaultDialer
View Source
var DefaultUpgrader = Upgrader{Upgrader: websocket.Upgrader{
	ReadBufferSize:    2048,
	WriteBufferSize:   2048,
	WriteBufferPool:   &sync.Pool{},
	EnableCompression: true,
}}

Functions

This section is empty.

Types

type Client added in v3.0.5

type Client struct {
	Dialer *websocket.Dialer
}

func (*Client) Connect added in v3.0.5

func (c *Client) Connect(address url.URL) (*Connection, error)

type Connection added in v3.0.5

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

func (*Connection) Close added in v3.0.5

func (c *Connection) Close()

func (*Connection) IsServer added in v3.0.5

func (c *Connection) IsServer() bool

IsServer returns true if the connection has server capabilities and not just a client. For now, we assume every connection with ping/pong handler is a server.

func (*Connection) Listen added in v3.0.5

func (c *Connection) Listen() chan struct{}

func (*Connection) SetMessageHandler added in v3.0.5

func (c *Connection) SetMessageHandler(fn MessageHandler)

func (*Connection) Write added in v3.0.5

func (c *Connection) Write(data []byte)

type MessageHandler added in v3.0.5

type MessageHandler func([]byte, error)

type Server added in v3.0.5

type Server struct {
	Upgrader *Upgrader
}

func (*Server) Connect added in v3.0.5

func (s *Server) Connect(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (*Connection, error)

type Upgrader

type Upgrader struct {
	websocket.Upgrader
	Origin string
}

func NewUpgrader

func NewUpgrader(origin string) *Upgrader

func (*Upgrader) Upgrade

func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (*websocket.Conn, error)

Jump to

Keyboard shortcuts

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