Sha256: f1cf68b1979c9fb7371a5b3005f7b5cbdf069cb1884f2ba30abb9bbb79171a2e
Contents?: true
Size: 1.13 KB
Versions: 26
Compression:
Stored size: 1.13 KB
Contents
#!/usr/bin/env ruby require 'dbus' require 'thread' Thread.abort_on_exception = true class Test < DBus::Object # Create an interface aggregating all upcoming dbus_method defines. dbus_interface "org.ruby.SampleInterface" do dbus_method :hello, "in name:s, in name2:s" do |name, name2| puts "hello(#{name}, #{name2})" end dbus_method :test_variant, "in stuff:v" do |variant| p variant end dbus_signal :SomethingJustHappened, "toto:s, tutu:u" end dbus_interface "org.ruby.AnotherInterface" do dbus_method :ThatsALongMethodNameIThink do puts "ThatsALongMethodNameIThink" end dbus_method :Reverse, "in instr:s, out outstr:s" do |instr| outstr = instr.split(//).reverse.join puts "got: #{instr}, replying: #{outstr}" [outstr] end end end bus = DBus::SessionBus.instance service = bus.request_service("org.ruby.service") myobj = Test.new("/org/ruby/MyInstance") service.export(myobj) Thread.new do i = 0 loop do # Signal emission myobj.SomethingJustHappened("hey", i += 1) sleep(0.5) end end puts "listening" main = DBus::Main.new main << bus main.run
Version data entries
26 entries across 26 versions & 5 rubygems