1

I am working with CoAP californium library using java and my problem is that I want to get the requested resource from client in the main function of server here ..

public static void main(String[] args) {
    // TODO Auto-generated method stub
    // binds on UDP port 5683
    CoapServer server=new CoapServer();
    // "hello"
    server.add(new HelloResource());
    // "subpath/Another"
    CoapResource path=new CoapResource("subpath");
    path.add(new AnotherResource());
    server.add(path);
    server.add(new RemovableResource(),new TimeResource(),new WritableResource());
    System.out.println("Resources added");
    server.start();
}

what I should write after server.start() .. I know that the server use function deliverRequest(final Exchange exchange) function and findResource(final List<String> list) to search for the requested resource in the reasources tree.. but I want to get this value and store it in a variable in the main function of server

Bence Kaulics
  • 7,843
  • 8
  • 42
  • 90

1 Answers1

1

Californium is designed to process many request simultaneously. Therefore it uses callbacks (CoapResource). May be I missunderstood your intention of the question. For me "all in main" sounds as an approach with a "blocking functions waiting for incoming requests and returning them". That is not intended with californium.

Achim Kraus
  • 246
  • 3
  • 5