Examples of HelloMessage


Examples of com.example.helloworld.resources.api.HelloMessage

@Produces(MediaType.APPLICATION_JSON)
public class JsonResource {

    @GET
    public HelloMessage sayHello() {
        return new HelloMessage("Hello, World!");
    }
View Full Code Here

Examples of com.jcloisterzone.wsio.message.HelloMessage

                listener.onWebsocketMessage(msg);
            }

            @Override
            public void onOpen(ServerHandshake arg0) {
                Connection.this.send(new HelloMessage(username));
            }
        };
        ws.connect();
    }
View Full Code Here

Examples of org.eclipse.ecf.examples.remoteservices.hello.HelloMessage

      proxy.hello(CONSUMER_NAME+" via proxy");
      System.out.println("COMPLETED remote call via proxy");
      System.out.println();
      // Call other helloMessage method
      System.out.println("STARTING remote call via proxy...");
      proxy.helloMessage(new HelloMessage(CONSUMER_NAME+" via proxy","howdy"));
      System.out.println("COMPLETED remote call via proxy");
      System.out.println();

      // If the proxy is also an instance of IHelloAsync then use
      // this asynchronous interface to invoke methods asynchronously
      if (proxy instanceof IHelloAsync) {
        IHelloAsync helloA = (IHelloAsync) proxy;
        // Create callback for use in IHelloAsync
        IAsyncCallback<String> callback = new IAsyncCallback<String>() {
          public void onSuccess(String result) {
            System.out.println("COMPLETED remote call with callback SUCCESS with result="+result);
            System.out.println();
          }
          public void onFailure(Throwable t) {
            System.out.println("COMPLETED remote call with callback FAILED with exception="+t);
            System.out.println();
          }
        };
       
        // Call asynchronously with callback
        System.out.println("STARTING async remote call via callback...");
        helloA.helloAsync(CONSUMER_NAME + " via async proxy with listener", callback);
        System.out.println("LOCAL async invocation complete");
        System.out.println();
       
        // Call asynchronously with future
        System.out.println("STARTING async remote call via future...");
        IFuture future = helloA.helloAsync(CONSUMER_NAME + " via async proxy with future");
        System.out.println("LOCAL async future invocation complete");
        System.out.println();
        try {
          while (!future.isDone()) {
            // do some other stuff
            System.out.println("LOCAL future not yet done...so we're doing other stuff while waiting for future to be done");
            Thread.sleep(200);
          }
          // Now it's done, so this will not block
          Object result = future.get();
          System.out.println("COMPLETED remote call with future SUCCEEDED with result="+result);
          System.out.println();
        } catch (OperationCanceledException e) {
          System.out.println("COMPLETED remote call with callback CANCELLED with exception="+e);
          System.out.println();
          e.printStackTrace();
        } catch (InterruptedException e) {
          System.out.println("COMPLETED remote call with callback INTERRUPTED with exception="+e);
          System.out.println();
          e.printStackTrace();
        }
       
        // Call other helloMessage method
        // Call asynchronously with callback
        System.out.println("STARTING async remote call via callback...");
        helloA.helloMessageAsync(new HelloMessage(CONSUMER_NAME + " via async proxy with listener","howdy"), callback);
        System.out.println("LOCAL async invocation complete");
        System.out.println();
       
        // Call asynchronously with future
        System.out.println("STARTING async remote call via future...");
        future = helloA.helloMessageAsync(new HelloMessage(CONSUMER_NAME + " via async proxy with future","howdy"));
        System.out.println("LOCAL async future invocation complete");
        System.out.println();
        try {
          while (!future.isDone()) {
            // do some other stuff
View Full Code Here

Examples of org.eclipse.ecf.examples.remoteservices.hello.HelloMessage

    proxy.hello(CONSUMER_NAME+" via proxy");
    System.out.println("COMPLETED remote call via proxy");
    System.out.println();
    // Call other helloMessage method
    System.out.println("STARTING remote call via proxy...");
    proxy.helloMessage(new HelloMessage(CONSUMER_NAME+" via proxy","howdy"));
    System.out.println("COMPLETED remote call via proxy");
    System.out.println();

    // If the proxy is also an instance of IHelloAsync then use
    // this asynchronous interface to invoke methods asynchronously
    if (proxy instanceof IHelloAsync) {
      IHelloAsync helloA = (IHelloAsync) proxy;
      // Create callback for use in IHelloAsync
      IAsyncCallback callback = new IAsyncCallback<String>() {
        public void onSuccess(String result) {
          System.out.println("COMPLETED remote call with callback SUCCESS with result="+result);
          System.out.println();
        }
        public void onFailure(Throwable t) {
          System.out.println("COMPLETED remote call with callback FAILED with exception="+t);
          System.out.println();
        }
      };
     
      // Call asynchronously with callback
      System.out.println("STARTING async remote call via callback...");
      helloA.helloAsync(CONSUMER_NAME + " via async proxy with listener", callback);
      System.out.println("LOCAL async invocation complete");
      System.out.println();
     
      // Call asynchronously with future
      System.out.println("STARTING async remote call via future...");
      Future<String> future = helloA.helloAsync(CONSUMER_NAME + " via async proxy with future");
      System.out.println("LOCAL async future invocation complete");
      System.out.println();
      try {
        while (!future.isDone()) {
          // do some other stuff
          System.out.println("LOCAL future not yet done...so we're doing other stuff while waiting for future to be done");
          Thread.sleep(200);
        }
        // Now it's done, so this will not block
        String result = future.get();
        System.out.println("COMPLETED remote call with future SUCCEEDED with result="+result);
        System.out.println();
      } catch (OperationCanceledException e) {
        System.out.println("COMPLETED remote call with callback CANCELLED with exception="+e);
        System.out.println();
        e.printStackTrace();
      } catch (InterruptedException e) {
        System.out.println("COMPLETED remote call with callback INTERRUPTED with exception="+e);
        System.out.println();
        e.printStackTrace();
      } catch (ExecutionException e) {
        System.out.println("COMPLETED remote call with callback INTERRUPTED with exception="+e);
        System.out.println();
        e.printStackTrace();
      }
     
      // Call other helloMessage method
      // Call asynchronously with callback
      System.out.println("STARTING async remote call via callback...");
      helloA.helloMessageAsync(new HelloMessage(CONSUMER_NAME + " via async proxy with listener","howdy"), callback);
      System.out.println("LOCAL async invocation complete");
      System.out.println();
     
      // Call asynchronously with future
      System.out.println("STARTING async remote call via future...");
      future = helloA.helloMessageAsync(new HelloMessage(CONSUMER_NAME + " via async proxy with future","howdy"));
      System.out.println("LOCAL async future invocation complete");
      System.out.println();
      try {
        while (!future.isDone()) {
          // do some other stuff
View Full Code Here

Examples of org.eclipse.ecf.examples.remoteservices.hello.HelloMessage

      proxy.hello(CONSUMER_NAME+" via proxy");
      System.out.println("COMPLETED remote call via proxy");
      System.out.println();
      // Call other helloMessage method
      System.out.println("STARTING remote call via proxy...");
      proxy.helloMessage(new HelloMessage(CONSUMER_NAME+" via proxy","howdy"));
      System.out.println("COMPLETED remote call via proxy");
      System.out.println();

      // If the proxy is also an instance of IHelloAsync then use
      // this asynchronous interface to invoke methods asynchronously
      if (proxy instanceof IHelloAsync) {
        IHelloAsync helloA = (IHelloAsync) proxy;
        // Create callback for use in IHelloAsync
        IAsyncCallback<String> callback = new IAsyncCallback<String>() {
          public void onSuccess(String result) {
            System.out.println("COMPLETED remote call with callback SUCCESS with result="+result);
            System.out.println();
          }
          public void onFailure(Throwable t) {
            System.out.println("COMPLETED remote call with callback FAILED with exception="+t);
            System.out.println();
          }
        };
       
        // Call asynchronously with callback
        System.out.println("STARTING async remote call via callback...");
        helloA.helloAsync(CONSUMER_NAME + " via async proxy with listener", callback);
        System.out.println("LOCAL async invocation complete");
        System.out.println();
       
        // Call asynchronously with future
        System.out.println("STARTING async remote call via future...");
        Future<String> future = helloA.helloAsync(CONSUMER_NAME + " via async proxy with future");
        System.out.println("LOCAL async future invocation complete");
        System.out.println();
        try {
          while (!future.isDone()) {
            // do some other stuff
            System.out.println("LOCAL future not yet done...so we're doing other stuff while waiting for future to be done");
            Thread.sleep(200);
          }
          // Now it's done, so this will not block
          String result = future.get();
          System.out.println("COMPLETED remote call with future SUCCEEDED with result="+result);
          System.out.println();
        } catch (OperationCanceledException e) {
          System.out.println("COMPLETED remote call with callback CANCELLED with exception="+e);
          System.out.println();
          e.printStackTrace();
        } catch (InterruptedException e) {
          System.out.println("COMPLETED remote call with callback INTERRUPTED with exception="+e);
          System.out.println();
          e.printStackTrace();
        } catch (ExecutionException e) {
          System.out.println("COMPLETED remote call with callback INTERRUPTED with exception="+e);
          System.out.println();
          e.printStackTrace();
        }
       
        // Call other helloMessage method
        // Call asynchronously with callback
        System.out.println("STARTING async remote call via callback...");
        helloA.helloMessageAsync(new HelloMessage(CONSUMER_NAME + " via async proxy with listener","howdy"), callback);
        System.out.println("LOCAL async invocation complete");
        System.out.println();
       
        // Call asynchronously with future
        System.out.println("STARTING async remote call via future...");
        future = helloA.helloMessageAsync(new HelloMessage(CONSUMER_NAME + " via async proxy with future","howdy"));
        System.out.println("LOCAL async future invocation complete");
        System.out.println();
        try {
          while (!future.isDone()) {
            // do some other stuff
View Full Code Here

Examples of org.ethereum.net.p2p.HelloMessage

    List<Capability> capabilities = Arrays.asList(
        new Capability(Capability.ETH, EthHandler.VERSION),
        new Capability(Capability.SHH, ShhHandler.VERSION));
    int listenPort = SystemProperties.CONFIG.listenPort();

    return new HelloMessage(p2pVersion, helloAnnouncement,
        capabilities, listenPort, PEER_ID);
  }
View Full Code Here

Examples of org.ethereum.net.p2p.HelloMessage

    @Test
    public void test1() {
      String helloMessageRaw = "f87a8002a5457468657265756d282b2b292f76302e372e392f52656c656173652f4c696e75782f672b2bccc58365746827c583736868018203e0b8401fbf1e41f08078918c9f7b6734594ee56d7f538614f602c71194db0a1af5a77f9b86eb14669fe7a8a46a2dd1b7d070b94e463f4ecd5b337c8b4d31bbf8dd5646";
           
        byte[] payload = Hex.decode(helloMessageRaw);
        HelloMessage helloMessage = new HelloMessage(payload);
        logger.info(helloMessage.toString());

        assertEquals(P2pMessageCodes.HELLO, helloMessage.getCommand());
        assertEquals(2, helloMessage.getP2PVersion());
        assertEquals("Ethereum(++)/v0.7.9/Release/Linux/g++", helloMessage.getClientId());
        assertEquals(2,   helloMessage.getCapabilities().size());
        assertEquals(992, helloMessage.getListenPort());
        assertEquals(
            "1fbf1e41f08078918c9f7b6734594ee56d7f538614f602c71194db0a1af5a77f9b86eb14669fe7a8a46a2dd1b7d070b94e463f4ecd5b337c8b4d31bbf8dd5646",
            helloMessage.getPeerId());


    }
View Full Code Here

Examples of org.jboss.aerogear.simplepush.protocol.HelloMessage

            @Override
            public void handle(final Buffer buffer) {
                final MessageType messageType = JsonUtil.parseFrame(buffer.toString());
                switch (messageType.getMessageType()) {
                    case HELLO:
                        HelloMessage handshakeMessage = fromJson(buffer.toString(), HelloMessageImpl.class);
                        if (!writeHandlerMap.containsKey(handshakeMessage.getUAID())) {
                            handshakeMessage = new HelloMessageImpl(UUIDUtil.newUAID());
                        }
                        final HelloResponse helloResponse = simplePushServer.handleHandshake(handshakeMessage);
                        sock.write(new Buffer(toJson(helloResponse)));
                        uaid = helloResponse.getUAID();
View Full Code Here

Examples of org.jboss.aerogear.simplepush.protocol.HelloMessage

    @Test
    public void fromJson() {
        final String uaid = UUIDUtil.newUAID();
        final String json = "{\"messageType\": \"hello\", \"uaid\": \"" + uaid + "\", \"channelIDs\": [\"123abc\", \"efg456\"]}";
        final HelloMessage handshake = JsonUtil.fromJson(json, HelloMessageImpl.class);
        assertThat(handshake.getMessageType(), is(equalTo(MessageType.Type.HELLO)));
        assertThat(handshake.getUAID(), is(equalTo(uaid)));
        assertThat(handshake.getChannelIds(), hasItems("123abc", "efg456"));
    }
View Full Code Here

Examples of org.jboss.aerogear.simplepush.protocol.HelloMessage

    }

    @Test
    public void fromJsonWithoutUAID() {
        final String json = "{\"messageType\": \"hello\"}";
        final HelloMessage handshake = JsonUtil.fromJson(json, HelloMessageImpl.class);
        assertThat(handshake.getMessageType(), is(equalTo(MessageType.Type.HELLO)));
        assertThat(handshake.getUAID(), is(notNullValue()));
        assertThat(handshake.getChannelIds().isEmpty(), is(true));
    }
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.