コード例 #1
0
ファイル: FileupdateServer.java プロジェクト: junwuwei/TJWS2
  private boolean processWatchKey(WatchKey watchKey) {
    for (WatchEvent<?> event : watchKey.pollEvents()) {
      if (StandardWatchEventKinds.OVERFLOW == event.kind()) continue;
      try {
        session.getBasicRemote().sendObject(((Path) event.context()).toFile());
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    return watchKey.reset();
  }
  @OnOpen
  public void onOpen(Session session) {
    try {
      User person = new User();
      person.setName("john");
      person.setSurname("smith");
      person.setEmail("*****@*****.**");

      session.getBasicRemote().sendObject(person);

    } catch (Exception e) {
      e.printStackTrace();
    }
  }