Skip to content

HttpClientWrapper to use switch between using Java Http and Ok Http for android#335

Open
kalynstricklin wants to merge 10 commits intoopensensorhub:masterfrom
kalynstricklin:http-client-wrapper
Open

HttpClientWrapper to use switch between using Java Http and Ok Http for android#335
kalynstricklin wants to merge 10 commits intoopensensorhub:masterfrom
kalynstricklin:http-client-wrapper

Conversation

@kalynstricklin
Copy link

  • Added httpclientwrapper to use java or okhttp during runtime based on httpclient availability
  • Added oauth
  • Added register system datastreams to update existing datastreams instead of creating new ones

@kalynstricklin kalynstricklin marked this pull request as draft February 18, 2026 20:39
@kalynstricklin kalynstricklin marked this pull request as ready for review February 19, 2026 21:52
import org.sensorhub.impl.service.consys.client.ConSysApiClientConfig;
import org.sensorhub.impl.service.consys.resource.ResourceFormat;

public interface IHttpClient

Choose a reason for hiding this comment

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

We should probably make this more generic for a range of uses. For example, a driver could use this to send GET requests for sensor data and be compatible with Android by default. It also may be a good idea to have the client API and implementation live in sensorhub-core, but I'm not 100% sure

We cannot guarantee that the foi id on the local observations are the same as the ones registered on the remote node
@kalynstricklin
Copy link
Author

@earocorn Can you leave input on the foi id additions

@earocorn
Copy link

This re-adds logic to use FOI IDs that are created on the remote node, since we can't guarantee that both nodes use the same ID encoders / encoding mechanism (db vs no db).

Copy link
Member

@alexrobin alexrobin left a comment

Choose a reason for hiding this comment

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

I like the approach for allowing different IHttpClient implementations. However, this new code would break some existing functionality so please try to address my comments to avoid this. Thx, good job!

protected HttpClient http;
protected URI endpoint;
protected String token;
public ConSysApiClient(ConSysApiClientConfig config) throws SensorHubException {
Copy link
Member

Choose a reason for hiding this comment

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

I would like to keep the ConSysApi Client independent from the config object. Config objects are for modules but I also use the client w/o the module. I would like to keep using the builder and extend it with any parameter we need.

- changed text case of DataStream to match
- Updated getDataStreams to return all dataStreams without systemId argument and added unit test
- Added ITokenHandler interface and implemented it with Nick's OAuthTokenHandler
- Removed client config from builder and added builder code back with changes to auth
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

Successfully merging this pull request may close these issues.

3 participants