udpc

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitConn

func InitConn(ctx contextx.Context, lAddr *net.UDPAddr, f Handle) error

func LocalAddr

func LocalAddr() net.Addr

func SendBinaryMsg

func SendBinaryMsg(addr *net.UDPAddr, data []byte) error

func SendTextMsg

func SendTextMsg(addr *net.UDPAddr, data []byte) error

Types

type Client

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

func New

func New(ctx contextx.Context, opfs ...func(opt *ClientOption)) (*Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) SendBinaryMsg

func (c *Client) SendBinaryMsg(data []byte) error

func (*Client) SendTextMsg

func (c *Client) SendTextMsg(data []byte) error

type ClientOption

type ClientOption struct {
	MaxPkgSize   int
	WriteTimeout time.Duration
	OnMsgHandle  RespHandle
	SrcAddr      *net.UDPAddr
	TargetAddr   *net.UDPAddr
}

type Handle

type Handle func(rAddr *net.UDPAddr, msgType udpx.MsgType, payload []byte)

type Option

type Option struct {
	RAddr        *net.UDPAddr
	MaxPkgSize   int
	WriteTimeout time.Duration
}

type RespHandle

type RespHandle func(msgType udpx.MsgType, data []byte)

type SetConfig

type SetConfig func(maxPkgSize int)

Jump to

Keyboard shortcuts

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