serialize() public method

Returns the text describing this call file, ready to be spooled.
public serialize ( ) : string
return string
Example #1
0
 /**
  * (non-PHPdoc)
  * @see PAGI\CallSpool.ICallSpool::spool()
  */
 public function spool(CallFile $call, $schedule = false)
 {
     $filename = tempnam($this->_tmpDir, 'PAGICallFile');
     if ($filename === false) {
         throw new CallSpoolException('Could generate temporary filename');
     }
     if (@file_put_contents($filename, $call->serialize()) === false) {
         @unlink($filename);
         throw new CallSpoolException('Error writing: ' . $filename);
     }
     if ($schedule !== false) {
         if (@touch($filename, $schedule) === false) {
             @unlink($filename);
             throw new CallSpoolException('Error scheduling: ' . $filename);
         }
     }
     $newFilename = implode(DIRECTORY_SEPARATOR, array($this->_spoolDir, 'outgoing', basename($filename)));
     if (@rename($filename, $newFilename) === false) {
         @unlink($filename);
         throw new CallSpoolException('Error spooling: ' . $newFilename);
     }
     return $newFilename;
 }
Example #2
-1
use PAGI\DialDescriptor\SIPDialDescriptor;
use PAGI\DialDescriptor\DAHDIDialDescriptor;
$dialDescriptor = new DAHDIDialDescriptor('1949890333', 1);
$callFile = new CallFile($dialDescriptor);
$callFile->setContext('campaign');
$callFile->setExtension('failed');
$callFile->setVariable('foo', 'bar');
$callFile->setPriority('1');
$callFile->setMaxRetries('0');
$callFile->setWaitTime(10);
$callFile->setCallerId('some<123123>');
echo "Call file generated (DAHDI dial descriptor):\n";
echo $callFile->serialize();
echo "\n\n";
$dialDescriptor = new SIPDialDescriptor('24', 'example.com');
$callFile = new CallFile($dialDescriptor);
$callFile->setContext('default');
$callFile->setExtension('777');
$callFile->setVariable('foo', 'bar');
$callFile->setPriority('1');
$callFile->setMaxRetries('0');
$callFile->setWaitTime(10);
$callFile->setCallerId('some<123123>');
echo "Call file generated (SIP dial descriptor):\n";
echo $callFile->serialize();
echo "\n\n\n";
echo "Spooling generated SIP call\n";
$spool = CallSpoolImpl::getInstance(array('tmpDir' => '/tmp', 'spoolDir' => '/tmp/spoolExample'));
$spool->spool($callFile);
echo "Spooling generated SIP call to run in 30 seconds\n";
$spool->spool($callFile, time() + 30);