1 package Tak::ObjectClient;
6 with 'Tak::Role::ObjectMangling';
8 has world => (is => 'ro', required => 1);
10 has remote => (is => 'lazy');
14 my $world = $self->world;
15 $world->remote_for('meta')->blocking_request(
16 register => object_service => 'Tak::ObjectService'
18 $world->remote_for('object_service')
21 sub proxy_method_call {
22 my ($self, @call) = @_;
23 my $ready = $self->encode_objects(\@call);
24 my $context = wantarray;
25 my @res = $self->remote->blocking_request(call_method => $context => $ready);
26 if ($res[0] eq 'RESULT') {
27 my $unpacked = $self->decode_objects($res[1]);
30 } elsif (defined $context) {
31 return $unpacked->[0];
41 my ($self, $proxy) = @_;
42 $self->remote->blocking_request(remove_object => $proxy->{tag});
46 my ($self, $tag) = @_;
47 bless({ client => $self, tag => $tag }, 'Tak::ObjectProxy');
51 my ($self, $obj) = @_;
52 unless (ref($obj) eq 'Tak::ObjectProxy') {
53 die "Can't deflate non-proxied object ${obj}";
55 return +{ __proxied_object__ => $obj->{tag} };
59 my ($self, $class, @args) = @_;
60 $self->proxy_method_call($class, 'new', @args);