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

udp/client: pools, messages and conversion #325

Closed
daenney opened this issue Apr 26, 2022 · 1 comment
Closed

udp/client: pools, messages and conversion #325

daenney opened this issue Apr 26, 2022 · 1 comment

Comments

@daenney
Copy link

daenney commented Apr 26, 2022

I'm trying to rewrite something that was written with the old/pre-v1 go-coap implementation, but I'm struggling a bit with all the different message types, pools and how to use them.

My case is pretty simple, I just have a client that needs to Get and Post a few things and then does an Observe. In doing so I ended up with something basic like:

cl, _ := udp.Dial(...)
cl.Post(...) 

The problem I'm running into is with Observe. The messages I get back from there are confirmable, and I have to confirm them otherwise after a while the server assumes the client is dead and stops sending data.

So you get something like

if msg.Type() == udpmsg.Confirmable {
  // do something
}

The problem I'm running into is that I'd like to use the pool.Message here to build up the message, because it has many useful functions like the different SetXXXers, instead of having to do this myself in udp/pool.Message by constantly allocation and growing the buffer to store the Options in etc.

However, there doesn't seem to be a way that I can convert from pool.Message to the equivalent udp/pool.Message, which is what WriteMessage() on the udp,ClientConn returned by udp.Dial expects. udp/ClientConn.Client expects a message.Message and though I can go from udp/pool.Message to message.Message using udp/pool.ConvertTo, I can't seem to go from pool.Message to message.Message.

I sort of feel like I'm missing something here? It feels like there should be a way to use a convenient facility like pool.Message to build up a message and then pass that on somehow to the udp/tcp/dtls ClientConn or Client, but I can't put the pieces together.

Do I have to use udp/pool.Message and build up everything myself?

@jkralik jkralik mentioned this issue Jul 30, 2022
12 tasks
@jkralik
Copy link
Member

jkralik commented Oct 15, 2022

This was unified at v3 there is one pool package and one message package over tcp/dtls/udp packages. It is simpler to use it.

@daenney daenney closed this as completed Oct 15, 2022
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