@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()); }
public void handleMessage(List<Tweet> tweets, Session session) { TwitterSocket.tweets.addAll(0, tweets); handleMessage(Tweet.listToJsonArray(TwitterSocket.tweets).toString(), session); }