Search in sources :

Example 1 with SidExipired

use of org.apache.felix.upnp.basedriver.importer.core.event.message.SidExipired in project felix by apache.

the class Renewer method run.

public void run() {
    while (bool) {
        try {
            sleep(timeout);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        boolean ok = ctrl.subscribe(service, sid, 180000);
        if (ok) {
            // renew ok
            if (service.getTimeout() - time_before_renew > 0) {
                timeout = service.getTimeout() - time_before_renew;
            } else {
                timeout = service.getTimeout();
            }
        } else {
            // renew not ok
            bool = false;
            subqueue.enqueue(new SidExipired(sid, service));
        }
    }
}
Also used : SidExipired(org.apache.felix.upnp.basedriver.importer.core.event.message.SidExipired)

Example 2 with SidExipired

use of org.apache.felix.upnp.basedriver.importer.core.event.message.SidExipired in project felix by apache.

the class SubScriber method run.

public void run() {
    while (running) {
        Object msg = subQueue.dequeue();
        if (running) {
            if (msg instanceof FirstMessage) {
                FirstMessage firstmsg = (FirstMessage) msg;
                Service service = firstmsg.getService();
                if (!service.isSubscribed()) {
                    // is not subscribe
                    boolean ok = ctrl.subscribe(service, 120000);
                    String sid = "";
                    if (ok) {
                        // subcribe ok
                        sid = service.getSID();
                        firstmsg.setSid(sid);
                        monitor.addListener(sid, firstmsg.getListener());
                    } else {
                        // subscribe not ok
                        Activator.logger.log(LogService.LOG_ERROR, "Sucribe failed");
                    }
                } else {
                    // already subscribe
                    monitor.addListener(service.getSID(), firstmsg.getListener());
                }
            } else if (msg instanceof ListenerModified) {
                monitor.updateListener((ListenerModified) msg, subQueue, ctrl);
            } else if (msg instanceof ListenerUnRegistration) {
                ListenerUnRegistration unreg = (ListenerUnRegistration) msg;
                monitor.delListener(unreg.getListener(), ctrl);
            } else if (msg instanceof SidExipired) {
                Activator.logger.WARNING("[Importer] Please report the bug. Used code - should be checked and removed");
            }
        }
    }
}
Also used : ListenerUnRegistration(org.apache.felix.upnp.basedriver.importer.core.event.message.ListenerUnRegistration) SidExipired(org.apache.felix.upnp.basedriver.importer.core.event.message.SidExipired) ListenerModified(org.apache.felix.upnp.basedriver.importer.core.event.message.ListenerModified) FirstMessage(org.apache.felix.upnp.basedriver.importer.core.event.message.FirstMessage) LogService(org.osgi.service.log.LogService) Service(org.cybergarage.upnp.Service)

Aggregations

SidExipired (org.apache.felix.upnp.basedriver.importer.core.event.message.SidExipired)2 FirstMessage (org.apache.felix.upnp.basedriver.importer.core.event.message.FirstMessage)1 ListenerModified (org.apache.felix.upnp.basedriver.importer.core.event.message.ListenerModified)1 ListenerUnRegistration (org.apache.felix.upnp.basedriver.importer.core.event.message.ListenerUnRegistration)1 Service (org.cybergarage.upnp.Service)1 LogService (org.osgi.service.log.LogService)1