예제 #1
0
  @OnOpen
  public void open(Session session) {
    peers.add(session);
    Tweet tweet = new Tweet();
    tweet.setAuthor("THE SERVER");
    tweet.setMessage("Welcome! We will provide you with data " + "as soon as we have it available");
    List<Tweet> tweets = Arrays.asList(tweet);
    session.getAsyncRemote().sendText(Tweet.listToJsonArray(tweets).toString());

    logger.info("opened session with id " + session.getId());
  }
예제 #2
0
 public void handleMessage(List<Tweet> tweets, Session session) {
   TwitterSocket.tweets.addAll(0, tweets);
   handleMessage(Tweet.listToJsonArray(TwitterSocket.tweets).toString(), session);
 }