I started looking at what changes to CoapEndpoint would need to happen. Here's what I see:
* Use different Matcher that ignores Mids and only matches on tokens.
* Use different message Serializer
* Use Stack that skips reliability layer.
* Somehow allow Connector to cancel all exchanges for specified remote endpoint when TCP connection drops.
We could create a different endpoint implementation, but it'll likely have 90% in common with the original CoapEndpoint (could introduce abstract superclass to avoid duplication). An alternative approach would be to introduce "USE_RELIABLE_TRANSPORT" NetworkConfig property. If set:
* CoapEndpoint initializes TCP/TLS connector instead of UDP.
* Coap endpoint initializes MID-less matcher (we'll need to extract Matcher interface and have 2 implementations)
* Coap endpoint initializes different serializer (we'll need to introduce Serializer interface and have 2 implementations)
* Coap endpoitn passes Matcher to TcpConnector, so latter can invoke Matcher.cancelAllForRemoteEndpoint(ip/port pair) method when connection drops.
In this approach, the CoapConnector stays exactly the same as today (there are really no changes to it needed), but we change its behavior via different components (Matcher / Serliazer).
My preference is towards the latter method, it keeps CoapEndpoint clean, but for a single if in the constructor to inject different implementation of key interfaces (Matcher and Serializer). And that pattern is already used in other places within Californium. But I don't feel super strongly about that.
Thoughts?