client

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: MIT Imports: 12 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[T any] struct {
	Name string
	Addr string
	// TLS FILE
	CertFile string
	// TLS KEY
	KeyFile string
	// TLS
	TLSConfig *tls.Config

	Response *http.Response
	Header   http.Header

	HeartBeatTimeout  time.Duration
	HeartBeatInterval time.Duration
	ReconnectInterval time.Duration
	HeartBeat         func(conn Conn) error

	WriteBufferSize int
	ReadBufferSize  int
	DailTimeout     time.Duration
	SubProtocols    []string

	OnOpen         func(conn Conn)
	OnClose        func(conn Conn)
	OnMessage      func(conn Conn, messageType int, msg []byte)
	OnError        func(stream *socket.Stream[Conn], err error)
	OnException    func(err error)
	OnSuccess      func()
	OnReconnecting func()

	OnUnknown   func(conn Conn, message []byte, next Middle)
	PingHandler func(conn Conn) func(data string) error

	PongHandler func(conn Conn) func(data string) error

	Protocol protocol.Protocol
	// contains filtered or unexported fields
}

func (*Client[T]) Close

func (c *Client[T]) Close() error

func (*Client[T]) Conn

func (c *Client[T]) Conn() Conn

func (*Client[T]) Connect

func (c *Client[T]) Connect()

func (*Client[T]) GetDailTimeout

func (c *Client[T]) GetDailTimeout() time.Duration

func (*Client[T]) GetRouter

func (c *Client[T]) GetRouter() *router.Router[*socket.Stream[Conn], T]

func (*Client[T]) LocalAddr

func (c *Client[T]) LocalAddr() net.Addr

func (*Client[T]) RemoteAddr

func (c *Client[T]) RemoteAddr() net.Addr

func (*Client[T]) Sender

func (c *Client[T]) Sender() socket.Emitter[Conn]

func (*Client[T]) SetRouter

func (c *Client[T]) SetRouter(router *router.Router[*socket.Stream[Conn], T]) *Client[T]

func (*Client[T]) Use

func (c *Client[T]) Use(middle ...func(Middle) Middle)

type Conn

type Conn interface {
	Name() string
	SetName(name string)
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
	Close() error
	Write(messageType int, data []byte) (int, error)
	Read() (int, []byte, error)
	LastPong() time.Time
	SetLastPong(t time.Time)
	Ping() error
	Pong() error
	Conn() *websocket.Conn
	SubProtocols() []string
	SetDeadline(t time.Time) error
	socket.Packer
}

type Middle

type Middle router.Middle[*socket.Stream[Conn]]

Jump to

Keyboard shortcuts

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