Coder Social home page Coder Social logo

Comments (5)

jkralik avatar jkralik commented on June 22, 2024

Request contains client that provides call NewMessage.
Eg:

req.Client.NewMessage(coap.MessageParams{
   	Type:  NonConfirmable,
   	...
})

Is it helps you?

from go-coap.

palsivertsen avatar palsivertsen commented on June 22, 2024

Yes, that would help. Thanks!

from go-coap.

palsivertsen avatar palsivertsen commented on June 22, 2024

Shouldn't coap.ResponseWriter.WriteMsg if there's no ACK of a CON message?

I'm running the observe client/server example like so:
server/main.go:

....
func sendResponse(w coap.ResponseWriter, req *coap.Request, subded time.Time) error {
  resp := req.Client.NewMessage(coap.MessageParams{
    Type: coap.Confirmable,
    Code: coap.Content,
  })  
  resp.SetOption(coap.ContentFormat, coap.TextPlain)
  resp.SetObserve(5)
  resp.SetPayload([]byte(fmt.Sprintf("Been running for %v", time.Since(subded))))
  return w.WriteMsg(resp)
}
...

from go-coap.

jkralik avatar jkralik commented on June 22, 2024

But i think you need to set Token and MessageId(for udp) because the client cannot pair notification..... something like:

func sendResponse(w coap.ResponseWriter, req *coap.Request, subded time.Time) error {
  resp := req.Client.NewMessage(coap.MessageParams{
    Type: coap.Confirmable,
    Code: coap.Content,
    MessageID: req.Msg.MessageID(),
    Token:     req.Msg.Token(),
  })  
  resp.SetOption(coap.ContentFormat, coap.TextPlain)
  resp.SetObserve(5)
  resp.SetPayload([]byte(fmt.Sprintf("Been running for %v", time.Since(subded))))
  return w.WriteMsg(resp)
}
...

from go-coap.

jkralik avatar jkralik commented on June 22, 2024

I will close this issue. Please if you have still problem please reopen it. Thx

from go-coap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.