Search in sources :

Example 1 with Property

use of org.cybergarage.upnp.event.Property in project felix by apache.

the class MyCtrlPoint method newEventArrived.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.apache.felix.upnpbase.importer.MyEventListener#newEventArrived(java.lang.String,
	 *      long, java.util.Dictionary)
	 */
public void newEventArrived(String uuid, long seq, PropertyList props) {
    Activator.logger.DEBUG("[Importer] newEventArrived");
    Service service = serviceFromSid(uuid);
    if (service != null) {
        int size = props.size();
        Hashtable hash = new Hashtable();
        for (int i = 0; i < size; i++) {
            Property prop = props.getProperty(i);
            String varName = prop.getName();
            String varValue = prop.getValue();
            String upnpType = service.getStateVariable(varName).getDataType();
            Object valueObj;
            try {
                valueObj = Converter.parseString(varValue, upnpType);
            } catch (Exception e) {
                Activator.logger.ERROR("[Importer] Bad data value in Notify event: " + "var name=" + varName + " value=" + varValue + " type=" + upnpType + "\n" + e);
                return;
            }
            hash.put(varName, valueObj);
        }
        Device device = service.getDevice();
        StateChanged msg = new StateChanged(uuid, seq, hash, device, service);
        notifierQueue.enqueue(msg);
    }
}
Also used : Hashtable(java.util.Hashtable) UPnPDevice(org.osgi.service.upnp.UPnPDevice) Device(org.cybergarage.upnp.Device) UPnPService(org.osgi.service.upnp.UPnPService) Service(org.cybergarage.upnp.Service) StateChanged(org.apache.felix.upnp.basedriver.importer.core.event.message.StateChanged) Property(org.cybergarage.upnp.event.Property) ControlPoint(org.cybergarage.upnp.ControlPoint) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException)

Example 2 with Property

use of org.cybergarage.upnp.event.Property in project i2p.i2p by i2p.

the class ControlPoint method httpRequestRecieved.

public void httpRequestRecieved(HTTPRequest httpReq) {
    if (Debug.isOn() == true)
        httpReq.print();
    // Thanks for Giordano Sassaroli <sassarol@cefriel.it> (09/08/03)
    if (httpReq.isNotifyRequest() == true) {
        NotifyRequest notifyReq = new NotifyRequest(httpReq);
        String uuid = notifyReq.getSID();
        long seq = notifyReq.getSEQ();
        PropertyList props = notifyReq.getPropertyList();
        int propCnt = props.size();
        for (int n = 0; n < propCnt; n++) {
            Property prop = props.getProperty(n);
            String varName = prop.getName();
            String varValue = prop.getValue();
            performEventListener(uuid, seq, varName, varValue);
        }
        httpReq.returnOK();
        return;
    }
    httpReq.returnBadRequest();
}
Also used : PropertyList(org.cybergarage.upnp.event.PropertyList) NotifyRequest(org.cybergarage.upnp.event.NotifyRequest) Property(org.cybergarage.upnp.event.Property)

Aggregations

Property (org.cybergarage.upnp.event.Property)2 Hashtable (java.util.Hashtable)1 StateChanged (org.apache.felix.upnp.basedriver.importer.core.event.message.StateChanged)1 ControlPoint (org.cybergarage.upnp.ControlPoint)1 Device (org.cybergarage.upnp.Device)1 Service (org.cybergarage.upnp.Service)1 NotifyRequest (org.cybergarage.upnp.event.NotifyRequest)1 PropertyList (org.cybergarage.upnp.event.PropertyList)1 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)1 UPnPDevice (org.osgi.service.upnp.UPnPDevice)1 UPnPService (org.osgi.service.upnp.UPnPService)1