public static void sendImage(MediaFeedData feed, WebSocket.Out<JsonNode> out) { if (feed != null) { Logger.info(" image id:" + feed.getId()); Caption caption = feed.getCaption(); Images images = feed.getImages(); ObjectNode msg = Json.newObject(); msg.put("kind", "newImage"); msg.put("id", feed.getId()); msg.put("createdTime", feed.getCreatedTime()); if (caption != null) { msg.put("authorFullName", caption.getFrom().getFullName()); msg.put("authorPic", caption.getFrom().getProfilePicture()); } msg.put("nLikes", feed.getLikes().getCount()); msg.put("uLikes", feed.getLikes().getLikesUserList().toString()); msg.put("nComments", feed.getComments().getCount()); msg.put("uComments", feed.getComments().getComments().toString()); msg.put("stdImageUrl", images.getStandardResolution().getImageUrl()); out.write(msg); } } // sendImage
/** * Iterate connection list and write incoming message back * * @param message, message to write */ public static void notifyAll(String message) { for (WebSocket.Out<String> out : wsConnections) { out.write(message); } }