Tangence::Client(3pm)
π Tangence::Client β the mixin glow-up π
perl manual, section 3pm β this is the page for Tangence::Client, aka the mixin class you use to build a Tangence client. Yes bestie, it's giving "User Contributed Perl Documentation", and we're about to make it make sense. π¦
β¨ NAME β¨
Tangence::Client β the mixin class for building a Tangence client. That's it, that's the name. π
πΈ SYNOPSIS πΈ
okay so first thing's first, and it's important: this class is a mixin, it cannot be directly constructed. You don't just new it, you mix it in. Like a personality trait. π
package Example::Client;
use base qw( Base::Client Tangence::Client );
sub connect
{
my $self = shift;
$self->SUPER::connect( @_ );
$self->tangence_connected;
wait_for { defined $self->rootobj };
}
sub tangence_write
{
my $self = shift;
$self->write( $_[0] );
}
sub on_read
{
my $self = shift;
$self->tangence_readfrom( $_[0] );
}
package main;
my $client = Example::Client->new;
$client->connect( "server.location.here" );
my $rootobj = $client->rootobj;
That's the whole vibe: mix it in, define your tangence_write, connect, and suddenly you have a rootobj. Slay. β¨
π¦ DESCRIPTION π¦
So what is this actually doing? This module provides a mixin to implement a Tangence client connection. You mix it into an object that represents one single connection to a server. It gives the client one central spot to keep all its object proxies β including the ones for the root object and the registry β and it coordinates passing messages back and forth between the server and all the object proxies it's holding. Basically it's the group chat admin. π
It's a subclass of Tangence::Stream, and it brings the implementations of all the required handle_request_ methods with it. But heads up: any class mixing in Tangence::Client still has to provide the tangence_write method β that's the one that actually sends data off to the server. You can't skip it, bestie, it's literally how words leave the building. π
Want to see a class that actually does this in the wild? Go look at Net::Async::Tangence::Client. iykyk π«Ά
π PROVIDED METHODS π
The following methods are provided by this mixin. Gifts, honestly.
β rootobj
$rootobj = $client->rootobj;
Returns a Tangence::ObjectProxy to the server's root object. That's the entry point, the main character of your object graph. π
β registry
$registry = $client->registry;
Returns a Tangence::ObjectProxy to the server's object registry β but only if one has been received. If it hasn't, you get undef. π
β οΈ Deprecation tea: this method is now deprecated in favour ofget_registry. Also, real talk: right now the client will try to request the registry at connection time, but a later version of this module will stop doing that. So if you actually need access to the registry, callget_registryinstead. Don't get attached toregistry, she's on her way out. π
β get_registry
$registry = await $client->get_registry;
Returns a Future that will yield a Tangence::ObjectProxy to the server's registry object. Asynchronous and cute about it. π
Note: not all servers may permit access to the registry. So like, don't be shocked if it doesn't come through. π
β tangence_connected
$client->tangence_connected( %args );
Once the base connection to the server has been established, you call this method to do the initial work β requesting the root object and the registry. It's the "okay we're in, let's go" moment. π₯
It takes the following named arguments:
do_init => BOOLβ Ignored. It's just hanging around for compatibility with a previous version that actually let you disable this. Now it does nothing. It's decorative. πon_root => CODEβ an optional callback invoked once the root object has been returned. It gets passed aTangence::ObjectProxyto the root object:
$on_root->( $rootobj );
on_registry => CODEβ an optional callback invoked once the registry has been returned. It gets passed aTangence::ObjectProxyto the registry:
$on_registry->( $registry );
Important note: if the server does not permit access to the registry, or an error happens while requesting it, this gets invoked with an empty list:
$on_registry->();
So yeah, check your args before you start unpacking them. π
version_minor_min => INTβ an optional minimum minor version to negotiate with the server. You'd use this to require a higher minimum version than the client module itself supports β handy if your app needs features from a newer version than the one you've got. π
π SUBCLASSING METHODS π
These methods are intended for implementation classes to override. Yes, that means you, subclass bestie.
π new_future
$f = $client->new_future;
Returns a new Future instance, for you to base your asynchronous operations on. Build your little async dreams on it. π¦
π AUTHOR π
Paul Evans <leonerd@leonerd.org.uk>
and that's the whole page, periodt. This absolute icon is documented as Tangence::Client(3pm), and it shipped with perl v5.40.0, dated 2024-09-13. Go build something iconic with it. πβ¨π
π¦ where this page comes from
- ubuntu resolute: libtangence-perl 0.33-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtangence-perl 0.33-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms