ws

package
v0.0.0-...-9c21ab8 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.Mutex
	Addr             string
	ConnNum          int
	ConnectInterval  time.Duration
	PendingWriteNum  int
	MaxMsgLen        uint32
	HandshakeTimeout time.Duration
	AutoReconnect    bool
	NewAgent         func(*Conn) network.Agent
	TextFormat       bool
	// contains filtered or unexported fields
}

func (*Client) Close

func (client *Client) Close()

func (*Client) Start

func (client *Client) Start()

type Conn

type Conn struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Conn) Close

func (wsConn *Conn) Close()

func (*Conn) Destroy

func (wsConn *Conn) Destroy()

func (*Conn) LocalAddr

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

func (*Conn) ReadMsg

func (wsConn *Conn) ReadMsg() ([]byte, error)

goroutine not safe

func (*Conn) RemoteAddr

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

func (*Conn) UserData

func (c *Conn) UserData() interface{}

func (*Conn) WriteMsg

func (wsConn *Conn) WriteMsg(args ...[]byte) error

args must not be modified by the others goroutines

type Handler

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

func (*Handler) ServeHTTP

func (handler *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Option

type Option func(*Server)

func WithAuthFunc

func WithAuthFunc(authFunc func(*http.Request) (bool, interface{})) Option

func WithHttpTimeout

func WithHttpTimeout(duration time.Duration) Option

func WithHttpsCert

func WithHttpsCert(cert, key string) Option

func WithMaxConnNum

func WithMaxConnNum(num int) Option

func WithMaxMsgLen

func WithMaxMsgLen(num uint32) Option

func WithPendingWriteNum

func WithPendingWriteNum(num int) Option

func WithTextFormat

func WithTextFormat(usingText bool) Option

type Server

type Server struct {
	Addr            string
	MaxConnNum      int
	PendingWriteNum int
	MaxMsgLen       uint32
	HTTPTimeout     time.Duration
	CertFile        string
	KeyFile         string
	NewAgent        func(*Conn) network.Agent
	AuthFunc        func(*http.Request) (bool, interface{})
	TextFormat      bool //纯文本还是二进制
	// contains filtered or unexported fields
}

func NewServer

func NewServer(port int, newAgentCallback func(*Conn) network.Agent, options ...Option) *Server

func (*Server) Close

func (server *Server) Close()

func (*Server) Start

func (server *Server) Start()

type WebsocketConnSet

type WebsocketConnSet map[*websocket.Conn]struct{}

Jump to

Keyboard shortcuts

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