ws

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn interface {
	ID() string
	Context() interface{}
	SetContext(ctx interface{})
	Close()
	Receive() (*Msg, error)
	Send(m *Msg) error
}

type ConnOption

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

type Msg

type Msg struct {
	Type    int
	Payload []byte
	// contains filtered or unexported fields
}

type Option

type Option func(opt *ConnOption)

func WithHBInterval

func WithHBInterval(hbInterval time.Duration) Option

func WithHandShakeTime

func WithHandShakeTime(hst time.Duration) Option

func WithIn

func WithIn(in int) Option

func WithOut

func WithOut(out int) Option

func WithReadBuffer

func WithReadBuffer(rb int) Option

func WithReadLimit

func WithReadLimit(rLimit int64) Option

func WithWriteBuffer

func WithWriteBuffer(wb int) Option

func WithWriteTime

func WithWriteTime(wt time.Duration) Option

type Server

type Server struct {
	*http.Server

	*ConnOption
	// contains filtered or unexported fields
}

func NewServer

func NewServer(opts ...ServerOption) *Server

func (*Server) Handler

func (s *Server) Handler(handler http.HandlerFunc)

func (*Server) NewSession

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

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

type ServerOption

type ServerOption func(*Server)

func Address

func Address(addr string) ServerOption

func ConnOpt

func ConnOpt(opts ...Option) ServerOption

func Handle

func Handle(handlers ...middleware.HTTPMiddleware) ServerOption

func Logger added in v1.3.7

func Logger(l logger.Logger) ServerOption

func Path

func Path(path string) ServerOption

func Timeout

func Timeout(rTimeout, wTimeout time.Duration) ServerOption

func WithNetwork

func WithNetwork(network string) ServerOption

type Session

type Session struct {
	sync.Mutex // avoid close chan duplicated
	*ConnOption
	// contains filtered or unexported fields
}

func (*Session) Close

func (s *Session) Close()

func (*Session) Context

func (s *Session) Context() interface{}

func (*Session) ID

func (s *Session) ID() string

func (*Session) Receive

func (s *Session) Receive() (*Msg, error)

func (*Session) Send

func (s *Session) Send(m *Msg) error

func (*Session) SetContext

func (s *Session) SetContext(ctx interface{})

Jump to

Keyboard shortcuts

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