ws

package
v0.0.0-...-ccc1604 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConnClosed        = errors.New("ws: conn is closed")
	ErrConnWriteChanFull = errors.New("ws: conn write channel is full")
	ErrConnWriteDataNil  = errors.New("ws: conn write data is nil")
)

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(name, addr string, newHandler func() gnet.Handler,
	opt ...Option) (c *Client, err error)

func (*Client) Addr

func (c *Client) Addr() string

func (*Client) Dial

func (c *Client) Dial(ctx context.Context) (gnet.Conn, error)

func (*Client) Name

func (c *Client) Name() string

func (*Client) String

func (c *Client) String() string

type Conn

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

func (*Conn) Close

func (c *Conn) Close()

func (*Conn) Done

func (c *Conn) Done() chan struct{}

func (*Conn) IsClosed

func (c *Conn) IsClosed() bool

func (*Conn) LocalAddr

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

func (*Conn) Name

func (c *Conn) Name() string

func (*Conn) RemoteAddr

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

func (*Conn) SetUserData

func (c *Conn) SetUserData(data any)

func (*Conn) Shutdown

func (c *Conn) Shutdown()

func (*Conn) String

func (c *Conn) String() string

func (*Conn) UserData

func (c *Conn) UserData() any

func (*Conn) Write

func (c *Conn) Write(data []byte) error

type Option

type Option func(o *options)

func WithBinary

func WithBinary() Option

func WithCheckOrigin

func WithCheckOrigin(checkOrigin func(_ *http.Request) bool) Option

func WithHandshakeTimeout

func WithHandshakeTimeout(handshakeTimeout time.Duration) Option

func WithKeepAlivePeriod

func WithKeepAlivePeriod(keepAlivePeriod time.Duration) Option

func WithMaxConnNum

func WithMaxConnNum(maxConnNum int) Option

func WithMaxReadDataSize

func WithMaxReadDataSize(maxReadDataSize int) Option

func WithMaxWriteDataSize

func WithMaxWriteDataSize(maxWriteDataSize int) Option

func WithPattern

func WithPattern(pattern string) Option

func WithReadTimeout

func WithReadTimeout(readTimeout time.Duration) Option

func WithText

func WithText() Option

func WithWriteChanSize

func WithWriteChanSize(writeChanSize int) Option

func WithWriteTimeout

func WithWriteTimeout(writeTimeout time.Duration) Option

type Server

type Server struct {
	*http.Server
	id.Tmp
	// contains filtered or unexported fields
}

func NewServer

func NewServer(name, addr string,
	newHandler func() gnet.Handler, opt ...Option) (s *Server, err error)

func (*Server) Addr

func (s *Server) Addr() string

func (*Server) ConnNum

func (s *Server) ConnNum() int

func (*Server) Name

func (s *Server) Name() string

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context)

func (*Server) String

func (s *Server) String() string

Jump to

Keyboard shortcuts

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