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

0

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.