use Object::Remote::MiniLoop;
use Object::Remote::Handle;
+use Module::Runtime qw(use_module);
sub new::on {
my ($class, $on, @args) = @_;
- Object::Remote::Handle->new(
- connection => $on,
- class => $class,
- args => \@args
- )->proxy;
+ my $conn = use_module('Object::Remote::Connection')->new_from_spec($on);
+ return $conn->new_remote(class => $class, args => \@args);
}
sub new {
sub new_from_spec {
my ($class, $spec) = @_;
+ return $spec if blessed $spec;
foreach my $poss (do { our @Guess }) {
if (my $obj = $poss->($spec)) { return $obj }
}
die "Couldn't figure out what to do with ${spec}";
}
+sub new_remote {
+ my ($self, @args) = @_;
+ Object::Remote::Handle->new(
+ connection => $self, @args
+ )->proxy;
+}
+
sub register_remote {
my ($self, $remote) = @_;
weaken($self->remote_objects_by_id->{$remote->id} = $remote);