Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a CoapMessage class/interface ? #83

Open
sbernard31 opened this issue Apr 19, 2024 · 4 comments
Open

Introduce a CoapMessage class/interface ? #83

sbernard31 opened this issue Apr 19, 2024 · 4 comments

Comments

@sbernard31
Copy link
Collaborator

I don't know if this is a good idea but I face some situation where I need to handle a coap request OR a coap (separated) response in a same way. This is not too surprising as from a CoAP RFC point of view all request and response are conceptually a CoAP Message.

In my case, I need the remote peer address and the transport context of the message.
See :

@szysas
Copy link
Collaborator

szysas commented Apr 22, 2024

Easy one would be to add helper method, would that be enough?

@sbernard31
Copy link
Collaborator Author

I'm not sure to see how it will looks like ?

@szysas
Copy link
Collaborator

szysas commented Apr 23, 2024

Something like:

static InetSocketAddress getPeerAddress(Object coap) {
...

static TransportContext getTransportContext(Object coap) {
...

@sbernard31
Copy link
Collaborator Author

OK I get it but my question was more about having a kind of Parent class (e.g. CoapMessage) for CoapRequest, CoapResponse, SeparatedResponse. At first sight (maybe I'm wrong) I think this could make java-coap user code more elegant.

Regarding adding this static method, to be honest, I'm not sure will really makes my user code better. 🤔

Anyway, maybe better to work first on #84 and see if you also need this kind of abstraction in java-coap code too ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants