NAME

xDash::Sender - Module for Sender's client script implementation

SYNOPSIS

#!/usr/bin/perl 
# xDash - Asynchronous Messaging and Instant Messaging reunited

#===
package EventLogger;
use base xDash::Logger::File;
# Check the correct file path for logger (absolute path if daemon!) and
# Uncomment 1.line and comment out 2.line below after debugging,
# sub Open { shift->SUPER::Open( '/home/xdash/sender/event.log' ) }
sub Open { shift->SUPER::Open( STDOUT ) }


package ErrorLogger;
use base xDash::Logger::File;
# Check the correct file path for logger (absolute path if daemon!)  and
# Uncomment 1.line and comment out 2.line below after debugging.
# sub Open { shift->SUPER::Open( '/home/xdash/sender/error.log' ) }
sub Open { shift->SUPER::Open( STDERR ) }

package MessageLogger;
# Uncomment the 1.line and comment out 2.&3. line below after debugging.
# use base xDash::Logger::Dumb;
use base xDash::Logger::File;
sub Open { shift->SUPER::Open( STDOUT ) }

package Spool;
# Test settings:
use base xDash::Spool::Dummy;
sub SetParameters { shift->SUPER::SetParameters( 
 event_limit => 10, mean_interoccurence_time => 1 )

# Change if you have your own implemantation or 
# Comment out the test settings above and uncomment the 1.&3.line below.
#use base xDash::Spool::Dir;
# Do not forget to create spool directory (absolute path if daemon!).
#sub SetParameters { shift->SUPER::SetDirPath( '/home/xdash/sender/spool' ) }
#===

package main;
use strict;
use warnings;
use xDash::Sender;

my $sender = new xDash::Sender;

# After debugging change:
# daemon => 1, for running as daemon (daemon => O, console usage)
# delay => 10, for waiting 10 seconds before becomming a daemon
# timeout => 100, for waiting 100 seconds to try to reconnect
# wait => 10, for waiting 10 seconds on the job confirmation from Archivist
# Test settings:
$sender->SetMode( daemon=> 0, delay=> 0, timeout=> 5, wait => 10 );

# Parameters from sender.xml and default connection parameters 
# from package Net::Jabber::Client (::Connect()) can be overriden here:
#	hostname => string, port => integer,
# 	connectiontype => tcpip|http, ssl => 0|1
# Uncomment if needed, method is optional.
# $sender->SetConnectionParameters( ... => ... , );

# Set Subject to everything, what helps to track jobs better 
# (below alias name from the archiv database).
$sender->SetJobSubject( 'sender_1' );

# Initiate Sender's and Archivist's JIDs (absolute path if daemon!)
$sender->SetParticipants( '/home/xdash/sender/sender.xml' );

# Spool check interval all 10 seconds, change if needed.
$sender->SetSpoolCheckInterval( 10 ); 

# A comma separated list of spool error numbers, on which Sender's script dies 
# and is restarted by the operating system.
$sender->SetRestartSpoolError( 1 );

# Go on ...
$sender->Process();

DESCRIPTION

USAGE

For detailed description, how xDash framework works, please refer to http://xdash.jabberstudio.org.

A convenient way for using the module and auto generating Sender's script is the utility xdscr from deployment directory. For script usage read the deployment/README.txt or usage information embedded into the script. The synopsis above is an example of the Sender's client script generated by the xdscr. You can find an introduction to the deployment: Planning and deploying xDash in a sandbox at http://xdash.jabberstudio.org/deployment/perl.

The module is developed in the object orientated way. You have to provide base classes for logging tasks and spool, which have to implement a fixed set of methods (driver pattern). You can use for logging xDash::Logger::File and xDash::Logger::Dumb in a way as it is proposed in the script generated by xdscr or provide your own implementation of the base class for EventLogger, ErrorLogger and MessageLogger. As spool you can use xDash::Spool::Dir and during testing xDash::Spool::Dummy as it is proposed in the script generated by xdscr. If you wish something else then a file system spool, you have to provide for the class Spool your own implementation of the base class. If you have to develop your own logger or spool, see provided modules source code for further implementation hints. If you think, they can be reused, make them public over CPAN in the xDash::Spool and xDash::Logger namespace!

METHODS

SetMode( daemon=> 0|1, delay=> $time, timeout=> $time, wait => $time )

daemon => 1, for running script as daemon; daemon => 0, console usage of the script; delay=> $time, for waiting $time seconds before becoming a daemon; timeout => $time, for waiting $time seconds to try to reconnect; wait => $time, for waiting $time seconds on the job confirmation from Archivist.

SetConnectionParameters( hostname => $string, port => $integer, connectiontype => tcpip|http, ssl => 0|1 )

Overrides parameters <hostname> and <port> from the XML configuration file (usually sender.xml) and default connection parameters from package Net::Jabber::Client (::Connect()). Method is optional.

SetJobSubject( $string )

Sets message subject to everything, what helps to track better jobs. Method is optional.

SetParticipants( $XML_configuration_file )

Initiate Sender's and Archivist's JIDs with a absolut path to the XML configuration file, usually with the name sender.xml.

SetSpoolCheckInterval( $time )

Sets spool check interval all $time seconds. Should be set in an individual manner according to the needs.

SetRestartSpoolError( $error_number_1, $error_number_2, ... )

Sets a comma separated list of spool error numbers on which the Sender's script dies and is restarted by the operating system.

Process( )

Go on...

BUGS

Any suggestions for improvement are welcomed!

If a bug is detected or nonconforming behavior, please send an error report to <jwach@cpan.org>. Please attache log entries, if possible.

COPYRIGHT

Copyright 2005 Jerzy Wachowiak <jwach@cpan.org>

This library is free software; you can redistribute it and/or modify it under the terms of the Apache 2.0 license attached to the module.

SEE ALSO

xDash::Logger::File
xDash::Logger::Dumb
xDash::Spool::Dir
xDash::Spool::Dummy
xDash::Receiver
xDash::Archivist
http://xdash.jabberstudio.org