0

I new in scala language.

I hame a method what takes on input CoapExchange object: def handlePOST (request: CoapExchange) { ..... How to convert org.eclipse.californium.core.server.resources.CoapExchange object to Byte[] in scala Thanks!!!

Orion
  • 59
  • 2
  • 10

1 Answers1

0

So, let's look at the source

And we find

/**
 * Gets the request payload as byte array.
 *
 * @return the request payload
 */
public byte[] getRequestPayload() {
    return exchange.getRequest().getPayload();
}

or you can use the documentation here

The Archetypal Paul
  • 41,321
  • 20
  • 104
  • 134
  • thx for your answer, but me need all request(body and headers) not a Payload – Orion May 01 '16 at 19:35
  • What do you mean by "all request"? All the bytes "on the wire", including message id etc? And why would you use Californium and still want that? – The Archetypal Paul May 01 '16 at 19:39
  • "-What do you mean by "all request"?": need all data what I getting from input(headers, message bode, port,url.....) "And why would you use Californium and still want that? – The Archetypal Paul just now": Total project requirement – Orion May 01 '16 at 19:44
  • OK, then I don't understand the requirement. It's like using (say) httpcommons and expecting to be able to get the entire stream of bytes sent back and forth on the TCP connection. The library probably just doesn't track that sort of thing. – The Archetypal Paul May 01 '16 at 19:46