has id => (is => 'rwp');
-has proxy => (is => 'lazy', weak_ref => 1);
-
-sub _build_proxy {
- bless({ remote => $_[0] }, 'Object::Remote::Proxy');
+sub proxy {
+ bless({ remote => $_[0], method => 'call' }, 'Object::Remote::Proxy');
}
sub BUILD {
$self->_await($self->connection->send(call => $self->id, $method, @args));
}
+sub call_discard {
+ my ($self, $method, @args) = @_;
+ $self->connection->send_discard(call => $self->id, $method, @args);
+}
+
sub _await {
my ($self, $future) = @_;
my $loop = $self->current_loop;
has local_objects_by_id => (is => 'ro', default => sub { {} });
-has remote_objects_by_id => (
- is => 'ro', default => sub { { NULL => bless({}, 'Object::Remote::Null') } }
-);
+has remote_objects_by_id => (is => 'ro', default => sub { {} });
has _json => (
is => 'lazy',
JSON::PP->new->filter_json_single_key_object(
__remote_object__ => sub {
my $id = shift;
+ return bless({}, 'Object::Remote::Null') if $id eq 'NULL';
(
$remotes->{$id}
or Object::Remote->new(connection => $self, id => $id)
sub send_discard {
my ($self, $type, @call) = @_;
- unshift @call, $type => { __remote_object => 'NULL' };
+ unshift @call, $type => { __remote_object__ => 'NULL' };
$self->_send(\@call);
}
sub receive_call {
my ($self, $future, $id, @rest) = @_;
+ $future->{method} = 'call_discard';
my $local = $self->local_objects_by_id->{$id}
or do { $future->fail("No such object $id"); return };
$self->_invoke($future, $local, @rest);
sub receive_class_call {
my ($self, $future, $class, @rest) = @_;
+ $future->{method} = 'call_discard';
eval { use_module($class) }
or do { $future->fail("Error loading ${class}: $@"); return };
$self->_invoke($future, $class, @rest);