source: project/release/4/dbus/trunk/examples/receive-car-turn.scm @ 31086

Last change on this file since 31086 was 31086, checked in by ecloud, 6 years ago

default-signal-handler takes 5 args: bus path svc iface mber

However maybe it's a bad idea because a dbus_message has more stuff, so
the handler doesn't get enough info to actually handle the signal.
But what kind of interface is that even if it could? The idea is this
egg is to be a nice high-level abstraction, not a way of digging around
in the bowels of how libdbus does things. And if we pass the whole message
to this handler, it's a C object, so what if the handler tries to keep it
for too long. Have never addressed GC yet anyway.

File size: 915 bytes
Line 
1(use (prefix dbus dbus:))
2
3(dbus:default-signal-handler (lambda (bus path svc iface mber)
4        ((dbus:printing-signal-handler) bus path svc iface mber)
5        (dbus:dump-callback-table)))
6
7(define (turn-right) (printf "car is turning to the right~%"))
8(define (turn-left) (printf "car is turning to the left~%"))
9
10(define rc-car-context (dbus:make-context
11        ; bus: dbus:session-bus         ;; would be the session-bus by default anyway
12        service: 'org.example.CarExample
13        path: '/Car
14        interface: 'org.example.Examples.CarInterface ))
15
16(dbus:enable-polling-thread!
17        ; bus: dbus:session-bus         ;; would be the session-bus by default anyway
18        enable: #f)
19
20(dbus:register-method rc-car-context "turnRight" turn-right)
21(dbus:register-method rc-car-context "turnLeft" turn-left)
22
23(let loop ()
24        ; (printf "poll~%")
25        ; (dbus:poll-for-message bus: dbus:session-bus) ;; would be the session-bus by default anyway
26        (dbus:poll-for-message)
27        (loop))
Note: See TracBrowser for help on using the repository browser.