my $code_container = $self->_id_to_remote_object(@_);
sub { $code_container->call(@_) };
}
+ )->filter_json_single_key_object(
+ __scalar_ref__ => sub {
+ my $value = shift;
+ return \$value;
+ }
);
}
sub register_class_call_handler {
my ($self) = @_;
- $self->local_objects_by_id->{'class_call_handler'}
- = Object::Remote::CodeContainer->new(
- code => sub {
- my ($class, $method) = splice @_, 0, 2;
- use_module($class)->$method(@_);
- }
- );
+ $self->local_objects_by_id->{'class_call_handler'} ||= do {
+ my $o = $self->new_class_call_handler;
+ $self->_local_object_to_id($o);
+ $o;
+ };
+}
+
+sub new_class_call_handler {
+ Object::Remote::CodeContainer->new(
+ code => sub {
+ my ($class, $method) = (shift, shift);
+ use_module($class)->$method(@_);
+ }
+ );
}
sub register_remote {
my ($self, $type, @call) = @_;
my $future = CPS::Future->new;
+ my $remote = $self->remote_objects_by_id->{$call[0]};
unshift @call, $type => $self->_local_object_to_id($future);
my $outstanding = $self->outstanding_futures;
$outstanding->{$future} = $future;
- $future->on_ready(sub { delete $outstanding->{$future} });
+ $future->on_ready(sub {
+ undef($remote);
+ delete $outstanding->{$future}
+ });
$self->_send(\@call);
sub _serialize {
my ($self, $data) = @_;
- local our @New_Ids;
+ local our @New_Ids = (-1);
return eval {
my $flat = $self->_encode($self->_deobjectify($data));
warn "$$ >>> ${flat}\n" if $DEBUG;
my ($self, $object) = @_;
my $id = refaddr($object);
$self->local_objects_by_id->{$id} ||= do {
- push our(@New_Ids), $id;
+ push our(@New_Ids), $id if @New_Ids;
$object;
};
return $id;
Object::Remote::CodeContainer->new(code => $data)
);
return +{ __remote_code__ => $id };
+ } elsif ($ref eq 'SCALAR') {
+ return +{ __scalar_ref__ => $$data };
} else {
die "Can't collapse reftype $ref";
}
$self->receive_free($id);
}
-sub receive_class_call {
- my ($self, $future_id, $class, @rest) = @_;
- my $future = $self->_id_to_remote_object($future_id);
- $future->{method} = 'call_discard_free';
- eval { use_module($class) }
- or do { $future->fail("Error loading ${class}: $@"); return };
- $self->_invoke($future, $class, @rest);
-}
-
sub _invoke {
my ($self, $future, $local, $ctx, $method, @args) = @_;
if ($method =~ /^start::/) {
}
1;
+
+=head1 NAME
+
+Object::Remote::Connection - An underlying connection for L<Object::Remote>
+
+=head1 LAME
+
+Shipping prioritised over writing this part up. Blame mst.
+
+=cut