package server
import "github.com/plgd-dev/go-coap/v3/tcp/server"
Index ¶
- Variables
- type Config
- type ErrorFunc
- type GoPoolFunc
- type HandlerFunc
- type Listener
- type OnNewConnFunc
- type Option
- type Server
Variables ¶
var DefaultConfig = func() Config { opts := Config{ Common: config.NewCommon[*client.Conn](), CreateInactivityMonitor: func() client.InactivityMonitor { maxRetries := uint32(2) timeout := time.Second * 16 onInactive := func(cc *client.Conn) { _ = cc.Close() } keepalive := inactivity.NewKeepAlive(maxRetries, onInactive, func(cc *client.Conn, receivePong func()) (func(), error) { return cc.AsyncPing(receivePong) }) return inactivity.New(timeout/time.Duration(maxRetries+1), keepalive.OnInactive) }, OnNewConn: func(*client.Conn) { }, RequestMonitor: func(*client.Conn, *pool.Message) (bool, error) { return false, nil }, ConnectionCacheSize: 2 * 1024, } opts.Handler = func(w *responsewriter.ResponseWriter[*client.Conn], _ *pool.Message) { if err := w.SetResponse(codes.NotFound, message.TextPlain, nil); err != nil { opts.Errors(fmt.Errorf("server handler: cannot set response: %w", err)) } } return opts }()
Types ¶
type Config ¶
type Config struct { config.Common[*client.Conn] CreateInactivityMonitor client.CreateInactivityMonitorFunc Handler HandlerFunc OnNewConn OnNewConnFunc RequestMonitor client.RequestMonitorFunc ConnectionCacheSize uint16 DisablePeerTCPSignalMessageCSMs bool DisableTCPSignalMessageCSM bool }
type ErrorFunc ¶
type ErrorFunc = func(error)
type GoPoolFunc ¶
type GoPoolFunc = func(func()) error
type HandlerFunc ¶
type HandlerFunc = func(*responsewriter.ResponseWriter[*client.Conn], *pool.Message)
The HandlerFunc type is an adapter to allow the use of ordinary functions as COAP handlers.
type Listener ¶
Listener defined used by coap
type OnNewConnFunc ¶
OnNewConnFunc is the callback for new connections.
type Option ¶
type Option interface { TCPServerApply(cfg *Config) }
A Option sets options such as credentials, codec and keepalive parameters, etc.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func New ¶
func (*Server) Serve ¶
func (*Server) Stop ¶
func (s *Server) Stop()
Stop stops server without wait of ends Serve function.
Source Files ¶
- Version
- v3.3.6 (latest)
- Published
- Sep 18, 2024
- Platform
- linux/amd64
- Imports
- 16 packages
- Last checked
- 1 week ago –
Tools for package owners.