#!/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( '/root/Ex1S1R/s.sandy@xdash_PC/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( '/root/Ex1S1R/s.sandy@xdash_PC/error.log' ) }
sub Open { shift->SUPER::Open( STDERR ) }

package MessageLogger;
# Uncomment the 1.line and comment out 2.line & 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.line & 3.line below.
#use base xDash::Spool::Dir;
# Do not forget to create spool directory (absolute path if daemon!).
#sub SetParameters { shift->SUPER::SetDirPath( '/root/Ex1S1R/s.sandy@xdash_PC/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 => 100, for waiting 100 seconds on the job confirmation from Archivist
# Test settings:
$sender->SetMode( daemon => 0, delay => 0, timeout => 100, wait => 100 );

# 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( 'sender1' );

# Initiate Sender's and Archivist's JIDs (absolute path if daemon!)
$sender->SetParticipants( '/root/Ex1S1R/s.sandy@xdash_PC/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();
