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

Have DefaultRegistrationEngine try to update reg after start #1579

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,28 @@ public void start() {
stop(false); // Stop without de-register
synchronized (this) {
started = true;
// Try factory bootstrap
// TODO support multi server
LwM2mServer dmServer = factoryBootstrap();

// TODO support multiple servers
LwM2mServer dmServer;
if (registeredServers.isEmpty()) {
// Try factory bootstrap
dmServer = factoryBootstrap();
} else {
dmServer = registeredServers.entrySet().iterator().next().getValue();
}
if (dmServer == null) {
// If it failed try client initiated bootstrap
if (!scheduleClientInitiatedBootstrap(NOW))
throw new IllegalStateException("Unable to start client : No valid server available!");
} else {
registerFuture = schedExecutor.submit(new RegistrationTask(dmServer));
// If there exists a registered server already, we try to send a registration update
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd actually be sceptical here. If a client is stopped, it should not keep registrations. So this situation should not be allowed.

If somebody truly needs a LWM2M client that supports this, they can either implement their own registration engine or subclass it.

I am not in favor of doing this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for taking time to look at this and also for sharing your opinion. 🙏

For now, no plan to integrate this BUT if for some reason we decide to ingrate it this will not be the default behavior.

if (!registeredServers.isEmpty()) {
String registrationId = registeredServers.entrySet().iterator().next().getKey();
UpdateRegistrationTask updateTask = new DefaultRegistrationEngine.UpdateRegistrationTask(dmServer,
registrationId, new RegistrationUpdate());
updateFuture = schedExecutor.submit(updateTask);
} else {
registerFuture = schedExecutor.submit(new DefaultRegistrationEngine.RegistrationTask(dmServer));
}
}
}
}
Expand Down