websocket

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TextMessage = websocket.TextMessage

	BinaryMessage = websocket.BinaryMessage
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr                           string
	HandshakeTimeout               time.Duration
	ReadBuffer                     int
	WriteBuffer                    int
	ReadTimeout, ReadHeaderTimeout time.Duration
	WriteTimeout                   time.Duration
	ShutdownTimeout                time.Duration
	CertFile, KeyFile              string
}

type Conn

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

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

func (*Conn) Read

func (c *Conn) Read(p []byte) (int, error)

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

func (*Conn) Write

func (c *Conn) Write(p []byte) (n int, err error)

type Handler

type Handler interface {
	OnConnection(rwc net.Conn)
}

type Option

type Option struct {
	Config

	Logger         logger.Logger
	MaxHeaderBytes int
	ConnState      func(net.Conn, http.ConnState)
	TLSConfig      *tls.Config
	TLSNextProto   map[string]func(*http.Server, *tls.Conn, http.Handler)
	ErrorLog       *log.Logger
	BaseContext    func(net.Listener) context.Context
	ConnContext    func(ctx context.Context, c net.Conn) context.Context
	CheckOrigin    func(r *http.Request) bool
	MessageType    int
}

type Server

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

func New

func New(opt Option) *Server

func (*Server) Handler

func (s *Server) Handler(handler Handler)

func (*Server) Run

func (s *Server) Run() error

func (*Server) ServeHTTP

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

func (*Server) Shutdown

func (s *Server) Shutdown() error

Jump to

Keyboard shortcuts

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