• Printable version
  • Tell by mail
  • Export to OpenOffice
  • Export to PDF
  • Export to csv
  • Export to Timeline
  • Add page to book
  • Tools:

Argonaut modules

Argonaut client works with modules. If you want to add functionality to argonaut client so that you'll be able to call it through argonaut protocol, you need to create an argonaut client module.

In order to do that, create a file named MyModule.pm which will be placed in Argonaut/ClientDaemon/Modules/ in perl path (usually /usr/share/perl5). In this file, write something that looks like this:

  # Some header with author, copyright and license information

  package Argonaut::ClientDaemon::Modules::MyModule;
  
  use strict;
  use warnings;
  
  use 5.008;
  
  use base qw(JSON::RPC::Procedure); # requires Perl 5.6 or later
  
  =item start
  execute MyModule complex operation on the computer
  =cut
  sub start : Public {
    my ($server, $args) = @_;     # $server is server object, $args is an arrayref with function args.
    my ($arg1,$arg2) = @{$args};  # So let's parse args
    $main::log->notice("MyModule has been called, it does complex stuff");    # Don't forget to log what you do, you got main::log for that
    my $result = $arg1+$arg2;     # Do you complex operation
    if ($result < 0) {
      die "Negative result!";     # Die errors are returned as an error following JSON-RPC protocol, so do not hesitate to die when something goes wrong
    }
    return $result;               # Return your result
  } # That's that simple ;-)
  
  1;
  
  __END__

For information on $server object, see http://search.cpan.org/~makamaka/JSON-RPC-0.96/lib/JSON/RPC/Server.pm .
You also may use arrayrefs $main::client_settings and $main::server_settings.
client_settings contains mac and ip addresses of the computer, along with the port argonaut is running on.
server_settings contains ip and port used by argonaut server.

Calling your modules functions

If you're using supportDaemon FusionDirectory class, calling your module function is as simple as calling action “MyModule.start”.
If you're directly using argonaut-server for some reason, you'll need to call “Argonaut.ClientDaemon.Modules.MyModule.start”

en/developers/argonaut_modules.txt · Last modified: 2017/10/31 10:40 (external edit)
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0