#!/usr/bin/env python3

from twisted.internet import reactor, defer

from txdbus           import client, error
from txdbus.interface import DBusInterface, Signal

signal_iface = DBusInterface( 'org.example.SignalSender',
                              Signal('tick', 'u')
                              )

def onSignal( tickCount ):
    print 'Got tick signal: ', tickCount

    
@defer.inlineCallbacks
def main():

    try:
        cli   = yield client.connect(reactor)

        robj  = yield cli.getRemoteObject( 'org.example', '/Signaller', signal_iface )

        robj.notifyOnSignal( 'tick', onSignal )
        
    except error.DBusException, e:
        print 'DBus Error:', e

                
reactor.callWhenRunning(main)
reactor.run()
