Citrix

 view release on metacpan or  search on metacpan

Citrix/LaunchMesg.pm  view on Meta::CPAN

package Citrix::LaunchMesg;
#use strict;
#use warnings;

use Storable ('dclone');
our $VERSION = '0.25';

# TODO:
# - Create a more precise description of what (keys) is in the session config sections
# DONE:
# - Now use accessors on Farm
# - Generate message into a string, no direct output.

=head1 NAME

Citrix::LaunchMesg - Generate Citrix session launch messages in format understood by Citrix Desktop Clients.

=head1 DESCRIPTION
 
Citrix::LaunchMesg Has methods for both initiating a totally new session and reconnecting
to an existing session. Depends on Net::DNS to resolve server hostname to IP Address
(convention used in Citrix launch messages).

For now please look into the file session_template.pl within module distro to learn about
launch message sections used for constructing the launch message (by Citrix::LaunchMesg::new()).

=head1 SYNOPSIS

   use Citrix::LaunchMesg;
   # Get "all farms" configuration (as indexed hash)
   my $fms = Citrix::getfarms('idx' => 1);
   
   # Pick Farm to launch session on
   my $fc = $fms->{'istanbul'};
   # (Perl hash) default-valued Templates for launch message sections
   my %sections = ('client' => $client, 'app' => $app, );
   my $clm = Citrix::LaunchMesg->new($fc, %sections);
   # Launch a new session (by Domain, Username, CitrixApp)
   my $err = $clm->setbalanced('hypertechno', 'joecitrix', 'DESKTOP-UNIX');
   # Send "launch.ica" to web browser to be processed by wfcmgr Citrix desktop client app.
   # When set via HTTP in a web application Need to add respective http headers
   # within application. Use 'application/x-ica' to launch Citrix client helper app. 
   print $clm->output();
   
   
   # ... Connect to existing session (after Citrix::LaunchMesg->new(...))
   # You should do app level checks that this session actually belongs to user launching it.
   # However the Citrix authentication phase still prevents abuse.
   $clm->sethostappsess("good-old-host-22:3567");
   print $clm->output();

=head1 METHODS

=cut




our ($foo, $bar);
# Keyword param Attributes of constructor for templates
our @tattr = ('client','app',);
# Translations for section names from runtime names to INI-section labels used in message
our %sectheads = ('client' => 'WFClient', 'app' => '',  'enc' => 'Encoding',  '' => '', );

=head2 my $clm = Citrix::LaunchMesg->new($farmctx, %opt);

Constructor for launch Message by Farm Context $farmctx, templates for various sections of
Citrix Launch message. This may later serve for launching a truly new session or connecting to
existing one. Options (%opt) are:

=over 4

=item client - Client Config section

=item app - Application Config section

=item inputenc - Input Encoding (optional, default: 'InputEncoding' => 'ISO8859_1')

=back

For an example / quick reference on above section see file 'session_template.pl' in source distribution.

=cut

sub new {
   my ($class, $fc, %c) = @_;
   my $lm = {
   	  'fc' => $fc,
      'enc'  => {'InputEncoding' => 'ISO8859_1',},
      'appx' => {},
      'appserv' => {$c{'appserv'} => '',},
   };
   $fc || die("Farm Missing");
   # Validate  templates passid in %c to be hashes. Also test contents ?
   for (@tattr) {(ref($c{$_}) eq 'HASH') || die("No Template for $_ passed");}
   bless($lm, $class);
   # Grab copies of templates for instance specific tweaks
   @$lm{@tattr} = map({dclone($c{$_});} @tattr);
   if ($c{'inputenc'}) {$lm->{'enc'}->{'InputEncoding'} = $c{'inputenc'};}
   return($lm);



( run in 1.228 second using v1.01-cache-2.11-cpan-df04353d9ac )