udp

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client(conn *net.UDPConn, opts ...DialOption) *client.ClientConn

Client creates client over udp connection.

func Dial

func Dial(target string, opts ...DialOption) (*client.ClientConn, error)

Dial creates a client connection to the given target.

Types

type BlockwiseFactoryFunc

type BlockwiseFactoryFunc = func(getSendedRequest func(token message.Token) (blockwise.Message, bool)) *blockwise.BlockWise

type BlockwiseOpt

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

BlockwiseOpt network option.

func WithBlockwise

func WithBlockwise(enable bool, szx blockwise.SZX, transferTimeout time.Duration) BlockwiseOpt

WithBlockwise configure's blockwise transfer.

type ContextOpt

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

ContextOpt handler function option.

func WithContext

func WithContext(ctx context.Context) ContextOpt

WithContext set's parent context of server.

type DialOption

type DialOption interface {
	// contains filtered or unexported methods
}

A DialOption sets options such as credentials, keepalive parameters, etc.

type ErrorFunc

type ErrorFunc = func(error)

type ErrorsOpt

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

ErrorsOpt errors option.

func WithErrors

func WithErrors(errors ErrorFunc) ErrorsOpt

WithErrors set function for logging error.

type EventFunc

type EventFunc = func()

type GoPoolFunc

type GoPoolFunc = func(func() error) error

type GoPoolOpt

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

GoPoolOpt gopool option.

func WithGoPool

func WithGoPool(goPool GoPoolFunc) GoPoolOpt

WithGoPool sets function for managing spawning go routines for handling incoming request's. Eg: https://github.com/panjf2000/ants.

type HandlerFunc

type HandlerFunc = func(*client.ResponseWriter, *pool.Message)

The HandlerFunc type is an adapter to allow the use of ordinary functions as COAP handlers.

type HandlerFuncOpt

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

HandlerFuncOpt handler function option.

func WithHandlerFunc

func WithHandlerFunc(h HandlerFunc) HandlerFuncOpt

WithHandlerFunc set handle for handling request's.

func WithMux

func WithMux(m mux.Handler) HandlerFuncOpt

WithMux set's multiplexer for handle requests.

type HeartBeatOpt

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

HeartBeatOpt heatbeat of read/write operations over connection.

func WithHeartBeat

func WithHeartBeat(heartbeat time.Duration) HeartBeatOpt

WithHeartBeat set deadline's for read/write operations over client connection.

type KeepAliveOpt

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

KeepAliveOpt keepalive option.

func WithKeepAlive

func WithKeepAlive(keepalive *keepalive.KeepAlive) KeepAliveOpt

WithKeepAlive monitoring's client connection's. nil means disable keepalive.

type MaxMessageSizeOpt

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

MaxMessageSizeOpt handler function option.

func WithMaxMessageSize

func WithMaxMessageSize(maxMessageSize int) MaxMessageSizeOpt

WithMaxMessageSize limit size of processed message.

type MulticastOption

type MulticastOption interface {
	// contains filtered or unexported methods
}

A MulticastOption sets options such as hop limit, etc.

type NetOpt

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

NetOpt network option.

func WithNetwork

func WithNetwork(net string) NetOpt

WithNetwork define's udp version (udp4, udp6, udp) for client.

type OnNewClientConnFunc

type OnNewClientConnFunc = func(cc *client.ClientConn)

type OnNewClientConnOpt

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

OnNewClientConnOpt network option.

func WithOnNewClientConn

func WithOnNewClientConn(onNewClientConn OnNewClientConnFunc) OnNewClientConnOpt

WithOnNewClientConn server's notify about new client connection.

type Server

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

func NewServer

func NewServer(opt ...ServerOption) *Server

func (*Server) Discover

func (s *Server) Discover(ctx context.Context, multicastAddr, path string, receiverFunc func(cc *client.ClientConn, resp *pool.Message), opts ...MulticastOption) error

Discover sends GET to multicast address and wait for responses until context timeouts or server shutdown.

func (*Server) DiscoveryRequest

func (s *Server) DiscoveryRequest(req *pool.Message, multicastAddr string, receiverFunc func(cc *client.ClientConn, resp *pool.Message), opts ...MulticastOption) error

DiscoveryRequest sends request to multicast addressand wait for responses until request timeouts or server shutdown.

func (*Server) GetMID

func (s *Server) GetMID() uint16

GetMID generates a message id for UDP-coap

func (*Server) Serve

func (s *Server) Serve(l *coapNet.UDPConn) error

func (*Server) Stop

func (s *Server) Stop()

Stop stops server without wait of ends Serve function.

type ServerOption

type ServerOption interface {
	// contains filtered or unexported methods
}

A ServerOption sets options such as credentials, codec and keepalive parameters, etc.

type Session

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

func NewSession

func NewSession(
	ctx context.Context,
	connection *coapNet.UDPConn,
	raddr *net.UDPAddr,
	maxMessageSize int,
) *Session

func (*Session) AddOnClose

func (s *Session) AddOnClose(f EventFunc)

func (*Session) Close

func (s *Session) Close() error

func (*Session) Context

func (s *Session) Context() context.Context

func (*Session) Done

func (s *Session) Done() <-chan struct{}

func (*Session) MaxMessageSize

func (s *Session) MaxMessageSize() int

func (*Session) RemoteAddr

func (s *Session) RemoteAddr() net.Addr

func (*Session) Run

func (s *Session) Run(cc *client.ClientConn) (err error)

func (*Session) WriteMessage

func (s *Session) WriteMessage(req *pool.Message) error

type TransmissionOpt

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

TransmissionOpt transmission options.

func WithTransmission

func WithTransmission(transmissionNStart time.Duration,
	transmissionAcknowledgeTimeout time.Duration,
	transmissionMaxRetransmit int) TransmissionOpt

WithTransmission set options for (re)transmission for Confirmable message-s.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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