Documentation
¶
Index ¶
- Variables
- type Config
- type Conn
- func (cc *Conn) AcquireMessage(ctx context.Context) *pool.Message
- func (cc *Conn) AddOnClose(f EventFunc)
- func (cc *Conn) AsyncPing(receivedPong func()) (func(), error)
- func (cc *Conn) CheckExpirations(now time.Time)
- func (cc *Conn) Close() error
- func (cc *Conn) Context() context.Context
- func (cc *Conn) Done() <-chan struct{}
- func (cc *Conn) LocalAddr() net.Addr
- func (cc *Conn) NetConn() net.Conn
- func (cc *Conn) ProcessReceivedMessage(req *pool.Message)
- func (cc *Conn) ProcessReceivedMessageWithHandler(req *pool.Message, handler HandlerFunc)
- func (cc *Conn) ReleaseMessage(m *pool.Message)
- func (cc *Conn) RemoteAddr() net.Addr
- func (cc *Conn) Run() (err error)
- func (cc *Conn) Sequence() uint64
- func (cc *Conn) Session() *Session
- func (cc *Conn) SetContextValue(key interface{}, val interface{})
- func (cc *Conn) WriteMessage(req *pool.Message) error
- type CreateInactivityMonitorFunc
- type ErrorFunc
- type EventFunc
- type GetMIDFunc
- type HandlerFunc
- type InactivityMonitor
- type Notifier
- type Session
- func (s *Session) AcquireMessage(ctx context.Context) *pool.Message
- func (s *Session) AddOnClose(f EventFunc)
- func (s *Session) CheckExpirations(now time.Time, cc *Conn)
- func (s *Session) Close() error
- func (s *Session) Context() context.Context
- func (s *Session) Done() <-chan struct{}
- func (s *Session) LocalAddr() net.Addr
- func (s *Session) NetConn() net.Conn
- func (s *Session) ReleaseMessage(m *pool.Message)
- func (s *Session) RemoteAddr() net.Addr
- func (s *Session) Run(cc *Conn) (err error)
- func (s *Session) Sequence() uint64
- func (s *Session) SetContextValue(key interface{}, val interface{})
- func (s *Session) WriteMessage(req *pool.Message) error
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = func() Config { opts := Config{ Common: config.NewCommon[*Conn](), CreateInactivityMonitor: func() InactivityMonitor { return inactivity.NewNilMonitor[*Conn]() }, Dialer: &net.Dialer{Timeout: time.Second * 3}, Net: "tcp", ConnectionCacheSize: 2048, } opts.Handler = func(w *responsewriter.ResponseWriter[*Conn], r *pool.Message) { switch r.Code() { case codes.POST, codes.PUT, codes.GET, codes.DELETE: if err := w.SetResponse(codes.NotFound, message.TextPlain, nil); err != nil { opts.Errors(fmt.Errorf("client handler: cannot set response: %w", err)) } } } return opts }()
Functions ¶
This section is empty.
Types ¶
type Conn ¶
Conn represents a virtual connection to a conceptual endpoint, to perform COAPs commands.
func NewConn ¶
func NewConn( connection *coapNet.Conn, createBlockWise func(cc *Conn) *blockwise.BlockWise[*Conn], inactivityMonitor InactivityMonitor, cfg *Config, ) *Conn
NewConn creates connection over session and observation.
func (*Conn) AddOnClose ¶
AddOnClose calls function on close connection event.
func (*Conn) AsyncPing ¶
AsyncPing sends ping and receivedPong will be called when pong arrives. It returns cancellation of ping operation.
func (*Conn) CheckExpirations ¶
CheckExpirations checks and remove expired items from caches.
func (*Conn) Context ¶
Context returns the client's context.
If connections was closed context is cancelled.
func (*Conn) Done ¶
func (cc *Conn) Done() <-chan struct{}
Done signalizes that connection is not more processed.
func (*Conn) NetConn ¶
NetConn returns the underlying connection that is wrapped by cc. The Conn returned is shared by all invocations of NetConn, so do not modify it.
func (*Conn) ProcessReceivedMessage ¶ added in v3.1.0
func (*Conn) ProcessReceivedMessageWithHandler ¶ added in v3.1.0
func (cc *Conn) ProcessReceivedMessageWithHandler(req *pool.Message, handler HandlerFunc)
func (*Conn) ReleaseMessage ¶
func (*Conn) Run ¶
Run reads and process requests from a connection, until the connection is not closed.
func (*Conn) SetContextValue ¶
func (cc *Conn) SetContextValue(key interface{}, val interface{})
SetContextValue stores the value associated with key to context of connection.
type CreateInactivityMonitorFunc ¶
type CreateInactivityMonitorFunc = func() InactivityMonitor
type GetMIDFunc ¶
type GetMIDFunc = func() int32
type HandlerFunc ¶
type HandlerFunc = func(*responsewriter.ResponseWriter[*Conn], *pool.Message)
type InactivityMonitor ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func NewSession ¶
func (*Session) AcquireMessage ¶
func (*Session) AddOnClose ¶
func (*Session) CheckExpirations ¶
CheckExpirations checks and remove expired items from caches.
func (*Session) Done ¶
func (s *Session) Done() <-chan struct{}
Done signalizes that connection is not more processed.
func (*Session) NetConn ¶
NetConn returns the underlying connection that is wrapped by s. The Conn returned is shared by all invocations of NetConn, so do not modify it.
func (*Session) ReleaseMessage ¶
func (*Session) RemoteAddr ¶
RemoteAddr gets remote address.
func (*Session) Run ¶
Run reads and process requests from a connection, until the connection is not closed.
func (*Session) SetContextValue ¶
func (s *Session) SetContextValue(key interface{}, val interface{})
SetContextValue stores the value associated with key to context of connection.