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

Add Callback on deletion in LwM2mInstanceEnabler #637

Closed
versatildefuy opened this issue Jan 11, 2019 · 6 comments
Closed

Add Callback on deletion in LwM2mInstanceEnabler #637

versatildefuy opened this issue Jan 11, 2019 · 6 comments
Labels
client Impact LWM2M client new feature New feature from LWM2M specification

Comments

@versatildefuy
Copy link

Hi guys,

first, thank you for your effort :)
We are working in a use case using both client and server. We are trying to disable an external component in the device when an instance is deleted, but I wasn't able to find any kind of callback or class for that without importing and adapting leshan-client-core and leshan-client-cf. A solution is reached modifying ObjectEnabler.class create and delete methods.
Is there any other way to handle these events?

@sbernard31
Copy link
Contributor

You are implementing a LwM2mInstanceEnabler and you would like to execute some code when the instance is deleted ?

I'm afraid there is nothing like this for now, but this could be a good improvement.

Waiting something like this was implementing (or contributing) you can create your own LwM2mObjectEnabler from BaseObjectEnabler (if you don't need the LwM2mInstanceEnabler) or from ObjectEnabler (if you still want to use LwM2mInstanceEnabler).

@sbernard31 sbernard31 added new feature New feature from LWM2M specification client Impact LWM2M client labels Jan 11, 2019
@sbernard31 sbernard31 changed the title [Leshan client] Handle instance deletion Add Callback on deletion in LwM2mInstanceEnabler Jan 11, 2019
@versatildefuy
Copy link
Author

Maybe the easiest way could be implementing a setter in ObjectsInitializer.class with the ObjectEnabler for the object as a parameter.

@sbernard31
Copy link
Contributor

If you create your own LwM2mObjectEnabler you didn't really need ObjectsInitializer.

Just add it to the collection manually :

initializer.setClassForObject(DEVICE, MyDevice.class);
initializer.setInstancesForObject(LOCATION, locationInstance);
//  .... ....
List<LwM2mObjectEnabler> enablers = initializer.create(SECURITY, SERVER, DEVICE, LOCATION);
// add your custom LwM2mObjectEnabler
enablers.add(new MyCustomObjectEnabler());

LeshanClientBuilder builder = new LeshanClientBuilder(endpoint);
builder.setObjects(enablers);
builder.build();

Just to know, is adding a onDelete() method on LwM2mInstanceEnabler would help ?

@versatildefuy
Copy link
Author

Just to know, is adding a onDelete() method on LwM2mInstanceEnabler would help ?

Yes, that would solve my problem

@sbernard31
Copy link
Contributor

I created a PR #641 to add onDelete().
Feedback would be really appreciated.

@sbernard31
Copy link
Contributor

#641 is now integrated in master so we can close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Impact LWM2M client new feature New feature from LWM2M specification
Projects
None yet
Development

No branches or pull requests

2 participants