コード例 #1
0
  // devp2p hello packet advertising version 55 and containing a few additional list elements
  @Test
  public void test1() {

    HelloMessage msg =
        new HelloMessage(
            decode(
                "f87137916b6e6574682f76302e39312f706c616e39cdc5836574683dc6846d6f726b1682270fb840"
                    + "fda1cff674c90c9a197539fe3dfb53086ace64f83ed7c6eabec741f7f381cc803e52ab2cd55d5569"
                    + "bce4347107a310dfd5f88a010cd2ffd1005ca406f1842877c883666f6f836261720304"));

    assertEquals(55, msg.getP2PVersion());
  }
コード例 #2
0
 @MessageMapping("/hello")
 public void greeting(SimpMessageHeaderAccessor headerAccessor, HelloMessage message)
     throws Exception {
   InetSocketAddress clientAddress =
       (InetSocketAddress) headerAccessor.getSessionAttributes().get("remoteAddress");
   String ip = clientAddress.getAddress().getHostAddress();
   String host = clientAddress.getHostName();
   LOG.info("Ping client");
   Thread.sleep(1000); // simulated delay
   String greetingMsg =
       String.format("Hello, %s! From ip: %s, hostname: %s", message.getName(), ip, host);
   messagingTemplate.convertAndSend("/cg/websockets/topic/greetings", new Greeting(greetingMsg));
 }
コード例 #3
0
 public static ByteBuf encode(HelloMessage helloMessage) throws UaException {
   return encode(
       MessageType.Hello,
       (b) -> HelloMessage.encode(helloMessage, b),
       Unpooled.buffer().order(ByteOrder.LITTLE_ENDIAN));
 }
コード例 #4
0
 @MessageMapping("/hello")
 @SendTo("/topic/greetings")
 public Greeting greeting(HelloMessage message) throws Exception {
   //        Thread.sleep(3000); // simulated delay
   return new Greeting("Hello, " + message.getName() + "!");
 }