Examples of XbmcConnector


Examples of org.openhab.binding.xbmc.rpc.XbmcConnector

      return;

    String xbmcInstance = xbmcProvider.getXbmcInstance(itemName);
    String property = xbmcProvider.getProperty(itemName);

    XbmcConnector connector = getXbmcConnector(xbmcInstance);
    if (connector != null) {
      // add the new 'watch'
      connector.addItem(itemName, property);
     
      // update the player status so any current value is initialised
      if (connector.isConnected()) {
        connector.updatePlayerStatus();
      }
     
      if (property.startsWith("Application")) {
        connector.requestApplicationUpdate();
      } else if (property.equals("System.State")) {
        connector.updateSystemStatus();
      }
    }
  }
View Full Code Here

Examples of org.openhab.binding.xbmc.rpc.XbmcConnector

    // sanity check
    if (xbmcInstance == null)
      return null;
   
    // check if the connector for this instance already exists
    XbmcConnector connector = connectors.get(xbmcInstance);
    if (connector != null)
      return connector;
   
    XbmcHost xbmcHost;
    if (xbmcInstance.startsWith("#")) {
      // trim off the '#' identifier
      String instance = xbmcInstance.substring(1);

      // check if we have been initialised yet - can't process
      // named instances until we have read the binding config
      if (nameHostMapper == null) {
        logger.trace("Attempting to access the named instance '{}' before the binding config has been loaded", instance);
        return null;
      }
     
      // check this instance name exists in our config
      if (!nameHostMapper.containsKey(instance)) {
        logger.error("Named instance '{}' does not exist in the binding config", instance);
        return null;
      }

      xbmcHost = nameHostMapper.get(instance);
    } else {
      xbmcHost = new XbmcHost();
      xbmcHost.setHostname(xbmcInstance);
    }   

    // create a new connection handler
    logger.debug("Creating new XbmcConnector for '{}' on {}", xbmcInstance, xbmcHost.getHostname());
    connector = new XbmcConnector(xbmcHost, eventPublisher);
    connectors.put(xbmcInstance, connector);
   
    // attempt to open the connection straight away
    try {
      connector.open();
    } catch (Exception e) {
      logger.error("Connection failed for '{}' on {}", xbmcInstance, xbmcHost.getHostname());
    }

    return connector;
View Full Code Here

Examples of org.openhab.binding.xbmc.rpc.XbmcConnector

   * {@inheritDoc}
   */
  @Override
  protected void execute() {
    for (Map.Entry<String, XbmcConnector> entry : connectors.entrySet()) {
      XbmcConnector connector = entry.getValue();
      if (connector.isConnected()) {
        // we are still connected but send a ping to make sure
        connector.ping();
        // refresh all players
        connector.updatePlayerStatus(true);
      } else {
        // broken connection so attempt to reconnect
        logger.debug("Broken connection found for '{}', attempting to reconnect...", entry.getKey());
        try {
          connector.open();
        } catch (Exception e) {
          logger.debug("Reconnect failed for '{}', will retry in {}s", entry.getKey(), refreshInterval / 1000);
        }
      }
    }
View Full Code Here

Examples of org.openhab.binding.xbmc.rpc.XbmcConnector

    try {
      // lookup the XBMC instance name and property for this item
      String xbmcInstance = getXbmcInstance(itemName);
      String property = getProperty(itemName);
     
      XbmcConnector connector = getXbmcConnector(xbmcInstance);
      if (connector == null) {
        logger.warn("Received command ({}) for item {} but no XBMC connector found for {}, ignoring", command.toString(), itemName, xbmcInstance);
        return;
      }
      if (!connector.isConnected()) {
        logger.warn("Received command ({}) for item {} but the connection to the XBMC instance {} is down, ignoring", command.toString(), itemName, xbmcInstance);
        return;
      }
     
      // TODO: handle other commands
      if (property.equals("Player.PlayPause"))
        connector.playerPlayPause();
      else if (property.equals("Player.Open"))
        connector.playerOpen(command.toString());
      else if (property.equals("Player.Stop"))     
        connector.playerStop();
      else if (property.equals("GUI.ShowNotification"))
        connector.showNotification("openHAB", command.toString());
      else if (property.equals("System.Shutdown") && command == OnOffType.OFF)
        connector.systemShutdown();
      else if (property.equals("System.Suspend") && command == OnOffType.OFF)
        connector.systemSuspend();
      else if (property.equals("System.Hibernate") && command == OnOffType.OFF)
        connector.systemHibernate();
      else if (property.equals("System.Reboot") && command == OnOffType.OFF)
        connector.systemReboot();
      else if (property.equals("Application.Volume"))
        connector.applicationSetVolume(command.toString());
    } catch (Exception e) {
      logger.error("Error handling command", e);
    }
  }
View Full Code Here

Examples of org.openhab.binding.xbmc.rpc.XbmcConnector

  protected void internalReceiveUpdate(String itemName, State newState) {
    try {
      String property = getProperty(itemName);

      String xbmcInstance = getXbmcInstance(itemName);
      XbmcConnector connector = getXbmcConnector(xbmcInstance);

      if (connector == null) {
        logger.warn("Received update ({}) for item {} but no XBMC connector found for {}, ignoring", newState.toString(), itemName, xbmcInstance);
        return;
      }
      if (!connector.isConnected()) {
        logger.warn("Received update ({}) for item {} but the connection to the XBMC instance {} is down, ignoring", newState.toString(), itemName, xbmcInstance);
        return;
      }

      // TODO: handle other updates
      if (property.equals("GUI.ShowNotification")) {
        connector.showNotification("openHAB", newState.toString());     
      } else if (property.equals("Player.Open")) {
        connector.playerOpen(newState.toString());
      } else if (property.equals("Application.SetVolume")) {
        connector.applicationSetVolume(newState.toString());
      }

    } catch (Exception e) {
      logger.error("Error handling update", e);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.