Examples of addMessageObserver()


Examples of ch.ethz.inf.vs.californium.coap.Request.addMessageObserver()

      System.out.println("+++++ Sending PUT +++++");
      Request asyncRequest = new Request(Code.PUT, Type.CON);
      asyncRequest.setURI(uri);
      asyncRequest.getOptions().setContentFormat((int) Math.random() * 0xFFFF + 1);
      asyncRequest.setPayload("Random");
      asyncRequest.addMessageObserver(new MessageObserverAdapter() {
        public void onResponse(Response response) {
          if (response != null) {
            checkInt(EXPECTED_RESPONSE_CODE_1.value,
                response.getCode().value, "code");
          }
View Full Code Here

Examples of ch.ethz.inf.vs.californium.coap.Request.addMessageObserver()

                System.out.println("++++ obs-reset PUT ++++");
                Request asyncRequest = new Request(Code.POST, Type.CON);
                asyncRequest.setPayload("sesame");
                asyncRequest.setURI(serverURI + "/obs-reset");
                asyncRequest.addMessageObserver(new MessageObserverAdapter() {
                    public void onResponse(Response response) {
                        if (response != null) {
                          System.out.println("Received: " + response.getCode());
                          System.out.println("+++++++++++++++++++++++");
                        }
View Full Code Here

Examples of ch.ethz.inf.vs.californium.coap.Request.addMessageObserver()

        // Delete the /obs resource of the server (either locally or by
        // having another CoAP client perform a DELETE request)
        System.out.println("+++++ Sending DELETE +++++");
        Request asyncRequest = new Request(Code.DELETE, Type.CON);
        asyncRequest.setURI(uri);
        asyncRequest.addMessageObserver(new MessageObserverAdapter() {
          public void onResponse(Response response) {
            if (response != null) {
              checkInt(EXPECTED_RESPONSE_CODE_1.value, response.getCode().value, "code");
            }
          }
View Full Code Here

Examples of ch.ethz.inf.vs.californium.coap.Request.addMessageObserver()

    dmtRes.removeAllChildren();
    dtmRes.reload();
   
    Request request = new Request(Code.GET);
    request.setURI(COAP_PROTOCOL+getHost()+"/.well-known/core");
    request.addMessageObserver(new MessageObserverAdapter() {
      @SuppressWarnings({ "rawtypes", "unchecked" })
      public void onResponse(Response response) {
        String text = response.getPayloadString();
        Scanner scanner = new Scanner(text);
        Pattern pattern = Pattern.compile("<");
View Full Code Here

Examples of ch.ethz.inf.vs.californium.coap.Request.addMessageObserver()

    cancel.setToken(request.getToken());
    cancel.setDestination(request.getDestination());
    cancel.setDestinationPort(request.getDestinationPort());
    // dispatch final response to the same message observers
    for (MessageObserver mo: request.getMessageObservers())
      cancel.addMessageObserver(mo);
    cancel.send();
    // cancel old ongoing request
    request.cancel();
    this.canceled = true;
  }
View Full Code Here

Examples of ch.ethz.inf.vs.californium.coap.Response.addMessageObserver()

//    block.setType(response.getType()); // NO! First block has type from origin response, all other depend on current request
    block.setDestination(response.getDestination());
    block.setDestinationPort(response.getDestinationPort());
    block.setToken(response.getToken());
    block.setOptions(new OptionSet(response.getOptions()));
    block.addMessageObserver(new TimeoutForwarder(response));
   
    if (response.getPayloadSize() > 0) {
      int currentSize = 1 << (4 + szx);
      int from = num * currentSize;
      int to = Math.min((num + 1) * currentSize, response.getPayloadSize());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.