Package com.almende.eve.rpc.jsonrpc

Examples of com.almende.eve.rpc.jsonrpc.JSONRequest


   
    // stop any running task
    stopAutoUpdate();

    // schedule an update task and store the task id
    JSONRequest request = new JSONRequest("update", null);
    String task = getScheduler().createTask(request, interval);
    state.put("updateTask", task);

    logger.info("Auto update started. Interval = " + interval
        + " milliseconds");
View Full Code Here


                }
              }
              return null;
            } else {
             
              final JSONRequest request = JSONRPC.createRequest(
                  method, args);
             
              final SyncCallback<JSONResponse> callback = new SyncCallback<JSONResponse>();
              final AsyncCallbackQueue<JSONResponse> cbs = host
                  .getCallbackQueue(proxyId,
                      JSONResponse.class);
              if (cbs != null) {
                cbs.push(request.getId(), "", callback);
              }
              try {
                host.sendAsync(receiverUrl, request, agent,
                    null);
              } catch (final IOException e1) {
View Full Code Here

          // this is important, it parallelizes dispatching of the messages
          String method = "dispatch";
          ObjectNode params = JOM.createObjectNode();
          params.put("url", url);
          params.put("message", JOM.getInstance().convertValue(message, ObjectNode.class));
          JSONRequest request = new JSONRequest(method, params);
         
          long delay = 1; // milliseconds
         
          getScheduler().createTask(request, delay);
        } catch (Exception e) {
View Full Code Here

          logger.info("request agentUrl =" + agentUrl + ", agentId="
              + agentId + " request=" + json + ", sender="
              + from.getId());
         
          // invoke the agent
          JSONRequest request = new JSONRequest(json);
          JSONResponse response = agentFactory.receive(agentId,
              request, params);
         
          // reply to message
          Message msg = new MessageBuilder().withRecipientJids(from)
View Full Code Here

              Agent agent = getAgent(id);
              return method.invoke(agent, args);
            }
            else {
              // remote agent
              JSONRequest request = JSONRPC.createRequest(method, args);
              JSONResponse response = send(senderId, receiverUrl, request);
             
              JSONRPCException err = response.getError();
              if (err != null) {
                throw err;
View Full Code Here

  }
 
  public String createTask(@Name("delay") long delay) throws Exception {
    ObjectNode params = JOM.createObjectNode();
    params.put("message", "hello world");
    JSONRequest request = new JSONRequest("myTask", params);
    String id = getScheduler().createTask(request, delay);
    return id;
  }
View Full Code Here

    System.out.println("testAsyncSend, url=" + url);
    String method = "multiply";
    ObjectNode params = JOM.createObjectNode();
    params.put("a", new Double(3));
    params.put("b", new Double(4.5));
    System.out.println("testAsyncXMPP, request=" + new JSONRequest(method, params));
    sendAsync(url, method, params, new AsyncCallback<Double>() {
      @Override
      public void onSuccess(Double result) {
        System.out.println("testAsyncXMPP result=" + result);
        ObjectNode params = JOM.createObjectNode();
View Full Code Here

    System.out.println("testSyncSend, url=" + url);
    String method = "multiply";
    ObjectNode params = JOM.createObjectNode();
    params.put("a", new Double(3));
    params.put("b", new Double(4.5));
    System.out.println("testSyncXMPP, request=" + new JSONRequest(method, params));
    Double result = send(url, method, params, Double.class);
    System.out.println("testSyncXMPP result=" + result);
    try {
      ObjectNode messageParams = JOM.createObjectNode();
      messageParams.put("result", result);
View Full Code Here

  public void testGetContacts (@Name("url") String url) throws Exception {
    System.out.println("testGetContacts, url=" + url);
    String method = "getContacts";
    ObjectNode params = JOM.createObjectNode();
    params.put("filter", "");
    System.out.println("testGetContacts, request=" + new JSONRequest(method, params));
    sendAsync(url, method, params, new AsyncCallback<ArrayNode>() {
      @Override
      public void onSuccess(ArrayNode result) {
        System.out.println("testGetContacts result=" + result);
        ObjectNode params = JOM.createObjectNode();
View Full Code Here

      throws Exception {
    // remove existing timeout
    cancelTimeToLive();
   
    // create a new timeout
    JSONRequest request = new JSONRequest("killMe", null);
    String timeoutId = getScheduler().createTask(request, interval);
    getState().put("timeoutId", timeoutId);
  }
View Full Code Here

TOP

Related Classes of com.almende.eve.rpc.jsonrpc.JSONRequest

Copyright © 2018 www.massapicom. 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.