plgd-dev / go-coap

Implementation of CoAP Server & Client in Go
https://coap.technology
Apache License 2.0
446 stars 116 forks source link

Ping (CON Empty Message) Notifications #500

Closed jeffwelder-ellenbytech closed 9 months ago

jeffwelder-ellenbytech commented 10 months ago

I would like my application to get notified of Confirmable Empty Message requests (Pings) to keep track of routable paths during observe.

Currently I believe this code prevents that from happening: https://github.com/plgd-dev/go-coap/blob/a48812ee4db5dbec9c8fb43496e8fc83dee79f7b/udp/client/conn.go#L785C2-L787C3

if r.Code() == codes.Empty && r.Type() == message.Confirmable && len(r.Token()) == 0 && len(r.Options()) == 0 && r.Body() == nil {
    cc.ProcessReceivedMessageWithHandler(r, cc.handlePong)
    return true
}

I would like to be able to handle this route either through router.DefaultHandle(), or passing in a configuration that allows you to create your own handlePong function.

Are there any concerns to bellying this up to the application?

jeffwelder-ellenbytech commented 9 months ago

Closed by #511