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: 9 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

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

	Mtu             int
	ReadBufferSize  int
	WriteBufferSize int
	DailTimeout     time.Duration

	OnOpen         func(conn Conn)
	OnClose        func(conn Conn)
	OnMessage      func(conn Conn, 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.UDPProtocol
	// 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
	Read(b []byte) (n int, addr *net.UDPAddr, err error)
	Write(b []byte) (int, error)
	WriteToUDP(b []byte, addr *net.UDPAddr) (int, error)
	Close() error
	Conn() *net.UDPConn
	LastPong() time.Time
	SetLastPong(t time.Time)
	Ping() error
	Pong() error
	SendClose() error
	SendOpen() error
	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