On 28.01.2018 20:31, Lino Urdiales wrote:
Hello everybody!
I'm working on a project where I have a CoAP server as middleware between CoAP clients and a message broker server (RabbitMQ server).
In order to properly handle the connections with the Message Broker server, I override the addObserveRelation(final
ObserveRelation relation)
function so every time a CoAP client connects with the CoAP server I establish a connection with the Message Broker server.
By overriding removeObserveRelation(ObserveRelation
relation)
I added all the functionality to disconnect from the Message Broker server for that session.
My concern is: Is this the best way to handle connections with the message broker server or does Californium offers a listener pattern design to properly open/close connections when the session with a CoAP client has stated/ended.
Assuming that you are talking about "overriding CoapResource.addObserveRelation()" then, in fact, there is a listener interface available that you should implement and register with your resource, instead of overriding "addObserveRelation":
org.eclipse.californium.core.server.resources.ResourceObserver
You can use its "addedObserveRelation" and "removedObserveRelation" methods to get notified, when a client starts or cancels an observation on your resource. Just register your observer using "CoapResource.addObserver()" when creating/registering your resource
with the CoapServer.
Hope to hear from you.
P. S. Great work to anyone involved in the project.
Thanks,
Kai
_______________________________________________
cf-dev mailing list
cf-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cf-dev
--
Mit freundlichen Grüßen / Best regards
Kai Hudalla
Chief Software Architect
Bosch Software Innovations GmbH
Ullsteinstraße 128
12109 Berlin
GERMANY
www.bosch-si.com
Registered Office: Berlin, Registration Court: Amtsgericht Charlottenburg; HRB 148411 B
Chairman of the Supervisory Board: Dr.-Ing. Thorsten Lücke; Managing Directors: Dr. Stefan Ferber, Michael Hahn
|