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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
# $Id: Event_RPC_Test.pm,v 1.4 2008/06/21 12:44:13 joern Exp $
#-----------------------------------------------------------------------
# Copyright (C) 2002-2005 Jrn Reder <joern AT zyn.de>.
# All Rights Reserved. See file COPYRIGHT for details.
#
# This module is part of Event::RPC, which is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#-----------------------------------------------------------------------
package Event_RPC_Test;
use Event_RPC_Test2;
use strict;
sub get_data { shift->{data} }
sub get_object2 { shift->{object2} }
sub set_data { shift->{data} = $_[1] }
sub set_object2 { shift->{object2} = $_[1] }
sub new {
my $class = shift;
my %par = @_;
my ($data) = $par{'data'};
my $self = bless {
data => $data,
object2 => Event_RPC_Test2->new("foo"),
}, $class;
return $self;
}
sub hello {
my $self = shift;
return "I hold this data: '".$self->get_data."'";
}
sub quit {
my $self = shift;
my $rpc_server = Event::RPC::Server->instance;
$rpc_server->get_loop->add_timer (
after => 1,
cb => sub { $rpc_server->stop },
);
return "Server stops in one second";
}
sub clone {
my $self = shift;
my $clone = (ref $self)->new (
data => $self->get_data
);
return $clone;
}
sub multi {
my $self = shift;
my ($num) = @_;
my (@list, %hash);
while ($num) {
push @list, $hash{$num} = (ref $self)->new ( data => $num );
--$num;
}
return (\@list, \%hash);
}
sub echo {
my $self = shift;
my (@params) = @_;
return @params;
}
sub get_cid {
my $self = shift;
my $connection = Event::RPC::Server->instance->get_active_connection;
my $cid = $connection->get_cid;
return $cid;
}
sub get_object_cnt {
my $self = shift;
my $connection = Event::RPC::Server->instance->get_active_connection;
my $client_oids = $connection->get_client_oids;
my $cnt = keys %{$client_oids};
return $cnt;
}
sub get_undef_object {
return undef;
}
sub new_object2 {
my $class = shift;
my ($data) = @_;
return Event_RPC_Test2->new($data);
}
1;
|