private void fillSession(PlexSession session, AbstractSessionItem item) { Player player = item.getPlayer(); session.setSessionKey(item.getSessionKey()); session.setState(PlexPlayerState.of(player.getState())); if (!isBlank(item.getGrandparentTitle())) { session.setTitle(item.getGrandparentTitle() + " - " + item.getTitle()); } else { session.setTitle(item.getTitle()); } session.setType(item.getType()); session.setMachineIdentifier(player.getMachineIdentifier()); if (isNumeric(item.getDuration())) { session.setDuration(Integer.valueOf(item.getDuration())); } session.setCover(getCover(item)); session.setKey(item.getKey()); }
@Override public void onMessage(String message) { logger.debug("[{}]: Message received: {}", connection.getUri().getHost(), message); SessionUpdate update = getSessionUpdateFrom(message); if (update != null && isNotBlank(update.getSessionKey())) { String sessionKey = update.getSessionKey(); String key = update.getKey(); String state = update.getState(); PlexSession session = getSession(sessionKey, key); if (!isBlank(state) && session != null) { PlexPlayerState playerState = PlexPlayerState.of(state); session.setState(playerState); session.setViewOffset(update.getViewOffset()); callback.updateReceived(session); } } }