-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver-example.pl
52 lines (46 loc) · 1.35 KB
/
server-example.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use XLLoop;
{
package TestHandler;
use Any::Moose;
has _functionInfo => (is => 'ro', isa => 'ArrayRef', default => \&_createFunctionInfo);
sub invoke {
my ($self, $context, $name, $args) = @_;
given ($name) {
when ('ArgsTest') {
return $args;
}
when ('ReturnTest') {
#return [1,1.2,'hello'];
#return [[1,2],['hello',4.1]];
return [0..100];
}
when ('MyTest') {
my ($a, $b) = @{$args};
return $a+$b;
}
when ('org.boris.xlloop.GetFunctions') {
return $self->_functionInfo;
}
default {
return "#Unknown function";
}
}
}
sub _createFunctionInfo {
my $a = [];
push @$a, FunctionInformation->new( name=>'ArgsTest', help=>'This is a args test')->getinfo;
my $f1 = FunctionInformation->new( name=>'MyTest', help=>'This is a dummy test');
$f1->addArg('anything', 'Test this one');
$f1->addArg('else', 'Whatever you like');
$f1->category('Testing');
push @$a, $f1->getinfo;
return $a;
}
}
my $h = TestHandler->new;
my $f = XLLoopServer->new( handler => $h );
$f->start;