You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
ifmsg.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?
The text was updated successfully, but these errors were encountered:
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: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
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 differentSetXXX
ers, instead of having to do this myself inudp/pool.Message
by constantly allocation and growing the buffer to store theOptions
in etc.However, there doesn't seem to be a way that I can convert from
pool.Message
to the equivalentudp/pool.Message
, which is whatWriteMessage()
on theudp,ClientConn
returned byudp.Dial
expects.udp/ClientConn.Client
expects amessage.Message
and though I can go fromudp/pool.Message
tomessage.Message
usingudp/pool.ConvertTo
, I can't seem to go frompool.Message
tomessage.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?The text was updated successfully, but these errors were encountered: