Closed jeffwelder-ellenbytech closed 9 months ago
@jkralik I reverted the changes to allow the package to process the Pings and attempted to extend an option through a WithPingMonitor()
function.
This option allows you to get a con object whenever a device pings the server. I modeled the option somewhat after the inactivityMonitor, and tried to extended it to udp/tcp/dtls.
Please let me know if there's a better way to do this. :)
@jkralik I reverted the changes to allow the package to process the Pings and attempted to extend an option through a
WithPingMonitor()
function.This option allows you to get a con object whenever a device pings the server. I modeled the option somewhat after the inactivityMonitor, and tried to extended it to udp/tcp/dtls.
Please let me know if there's a better way to do this. :)
This implementation is fine, however we talked about this with @jkralik today and we would prefer to change this from just a ping request monitor to a general request monitor to have a more general purpose feature. Any arguments why that could be problematic? If not then, please:
PingMonitorFunc
to RequestMonitorFunc
which takes two arguments (first is the connection as before, and extend it by a second argument which will be the request message pool.Message
)@Danielius1922 / @jkralik Thank you for reviewing, I like the suggestion!
I've extended the option to include the pool message alongside the connection:
type RequestMonitorFunc = func(cc *client.Conn, req *pool.Message)
IsPingMessage
is now reduced to a single return line, and exported.
Let me know if there are any more improvements I can make, or what the next steps are with appending to any tests.
@jeffwelder-ellenbytech Pls could you update the PR and fix the issue mentioned in https://github.com/plgd-dev/go-coap/pull/501#discussion_r1383503732
@jeffwelder-ellenbytech Pls could you update the PR and fix the issue mentioned in #501 (comment)
@jkralik Sure, using the func NewConnWithOpts(connection coapNet.Conn, cfg Config, opts ...Option)?
Allow ping request to be propagated to application handlers to allow application to keep track of devices that are pinging. This is useful when you have devices observing resources that have to ping to keep routes open.
See issue #500