home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / libnet-dbus-perl / examples / example-service-no-introspect.pl < prev    next >
Encoding:
Perl Script  |  2006-02-19  |  987 b   |  51 lines

  1. #!/usr/bin/perl
  2.  
  3. use Carp qw(confess cluck);
  4. use Net::DBus;
  5. use Net::DBus::Service;
  6. use Net::DBus::Reactor;
  7.  
  8. #...  continued at botom
  9.  
  10.  
  11. package SomeObject;
  12.  
  13. use base qw(Net::DBus::Object);
  14.  
  15. sub new {
  16.     my $class = shift;
  17.     my $service = shift;
  18.     my $self = $class->SUPER::new($service, "/SomeObject");
  19.     bless $self, $class;
  20.     
  21.     return $self;
  22. }
  23.  
  24. sub HelloWorld {
  25.     my $self = shift;
  26.     my $message = shift;
  27.     print "Do hello world\n";
  28.     print $message, "\n";
  29.     return ["Hello", " from example-service.pl"];
  30. }
  31.  
  32. sub GetDict {
  33.     my $self = shift;
  34.     print "Do get dict\n";
  35.     return {"first" => "Hello Dict", "second" => " from example-service.py"};
  36. }
  37.  
  38. sub GetTuple {
  39.     my $self = shift;
  40.     print "Do get tuple\n";
  41.     return ["Hello Tuple", " from example-service.py"];
  42. }
  43.  
  44. package main;
  45.  
  46. my $bus = Net::DBus->session();
  47. my $service = $bus->export_service("org.designfu.SampleService");
  48. my $object = SomeObject->new($service);
  49.  
  50. Net::DBus::Reactor->main->run();
  51.