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

[question] Sending a request from the coap_client #6

Closed
pedromassango opened this issue Apr 13, 2020 · 3 comments
Closed

[question] Sending a request from the coap_client #6

pedromassango opened this issue Apr 13, 2020 · 3 comments

Comments

@pedromassango
Copy link
Contributor

The send function from the coap_client class is not using the returned value from the prepape method, it hat right?

In the coap_client file we have this:

  /// Send
  Future<CoapResponse> send(CoapRequest request) async {
    await prepare(request);
    return request.send().waitForResponse(timeout);
  }

Here the prepare(request) return a CoapRequest. I'm wondering if we must use the returned request from the prepare function or it is ok that way.

@pedromassango
Copy link
Contributor Author

Cc: @shamblett

@shamblett
Copy link
Owner

Its actually OK but very unclear, the prepare method changes the request itself, it sets defaults, resolves the address and sets the endpoint, at this point the request is ready to be used. You could use the returned one but in this case seeing as we are doing no further preparation we don't need to.

The API documentation could make this clearer, also there may well be a better way to do all this. The coap client class is in many ways just supplies a convenient interface to users who don't want to build their own requests, this could be done this using builder classes instead.

@pedromassango
Copy link
Contributor Author

Thank you. I think I must close this for now

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