X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FObject-Remote.git;a=blobdiff_plain;f=lib%2FObject%2FRemote%2FConnection.pm;h=f46645229aed04218f83da296b0a0d6fbca48bd1;hp=291b5540820522822e2314c7f770f87f9f153148;hb=4c17fea55a562db315a029e6bd67b7dbb028a8e9;hpb=a980b0b8d4033a154d0e76caa63dab7899515639 diff --git a/lib/Object/Remote/Connection.pm b/lib/Object/Remote/Connection.pm index 291b554..f466452 100644 --- a/lib/Object/Remote/Connection.pm +++ b/lib/Object/Remote/Connection.pm @@ -92,12 +92,33 @@ BEGIN { 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 connect { + my ($self, $to) = @_; + return await_future($self->send( + class_call => 'Object::Remote', 0, connect => $to + )); +} + +sub get_remote_sub { + my ($self, $sub) = @_; + my ($pkg, $name) = $sub =~ m/^(.*)::([^:]+)$/; + return await_future($self->send(class_call => $pkg, 0, can => $name)); +} + sub register_remote { my ($self, $remote) = @_; weaken($self->remote_objects_by_id->{$remote->id} = $remote);