POE-Component-Telephony-CTPort

 view release on metacpan or  search on metacpan

CTPort.pm  view on Meta::CPAN

	$kernel->yield(put => sprintf('cmd=cthangup src=%d dst=%d argc=0',
		$heap->{handle},$heap->{d_handle}));
}

#	"ctwaitforring"
#		SUMMARY: 	Waits for a ring event and returns the caller ID if
#				available [blocking]
#		ARGS: 		arg1=<number of rings to wait for (def 2)>
#		RETURN ARGS: 	arg1=[OK|ERROR|EVENT]
#				arg2=<Caller ID>
#				arg3=<event>

=pod

=head2 wait_for_ring

Blocks until port detects a ring, then returns.  The caller
ID (if present) will be returned.

=cut

sub wait_for_ring {
	my ($kernel, $heap) = @_[KERNEL, HEAP];
	my $rings = $_[ARG0] || 2;
	my $ird = $_[ARG1] || 0;

	$kernel->yield(put =>
		sprintf('cmd=ctwaitforring src=%d dst=%d arg1=%d arg2=%s argc=2',
		$heap->{handle},$heap->{d_handle},$rings,$ird));
}

#	"ctwaitfordial"
#		SUMMARY:	Waits for a dialtone for a max of 10 seconds [blocking]
#		ARGS: 		none
#		RETURN ARGS:	arg1=[OK|ERROR]

=pod

=head2 wait_for_dial_tone

Blocks until dial tone detected on port, then returns.

=cut

sub wait_for_dial_tone {
	my ($kernel, $heap) = @_[KERNEL, HEAP];

	$kernel->yield(put => sprintf('cmd=ctwaitfordial src=%d dst=%d argc=0',
		$heap->{handle},$heap->{d_handle}));
}

#	"ctplaytoneasync"
#		SUMMARY:	plays a tone asyncronously [non-blocking]
#		ARGS: 		arg1=<tone type>
#		RETURN ARGS:	arg1=[OK|ERROR]

=pod

=head2 play_tone => $type

Plays a tone.  $type can be busy, dialx, dial, or ringback.
A warning is produced if you supply an invalid tone.

=cut

sub play_tone {
	my ($kernel, $heap, $type) = @_[KERNEL, HEAP, ARG0];
	$type = lc($type);
	
	my $found = 0;
	foreach my $t (qw(busy dialx dial ringback)) {
		$found = 1 if ($type eq $t);
	}
	unless ($found) {
		warn "play_tone: ctserver does not support tone $type";
		return;
	}

	$kernel->yield(put => sprintf('cmd=ctplaytoneasync src=%d dst=%d arg1=%s argc=1',
		$heap->{handle},$heap->{d_handle},$type));
}

#	"ctstoptone"
#		SUMMARY:	stops an asynronous tone playing [non-blocking]
#		ARGS: 		none
#		RETURN ARGS:	arg1=[OK|ERROR]

=pod

=head2 stop_tone

Stops a playing tone

=cut

sub stop_tone {
	my ($kernel, $heap) = @_[KERNEL, HEAP];

	$kernel->yield(put => sprintf('cmd=ctstoptone src=%d dst=%d argc=0',
		$heap->{handle},$heap->{d_handle}));
}

#	"ctplay_stop"
#		SUMMARY:	Stops an asyncronous play [non-blocking]
#		ARGS: 		none
#		RETURN ARGS:	arg1=[OK|ERROR]

=pod

=head2 play_stop

Stops current playback.

=cut

sub play_stop {
	my ($kernel, $heap) = @_[KERNEL, HEAP];

	$kernel->yield(put => sprintf('cmd=ctplay_stop src=%d dst=%d argc=0',
		$heap->{handle},$heap->{d_handle}));
}

=pod

=head2 play => $file _or_ play => \@files _or_ play => [ $file1, $file2, $file3 ]

Plays audio files, playing stops immediately if a DTMF key is 
pressed.  Any digits pressed while playing will be added to the digit buffer.

It accepts a space seperated list of files:
$kernel->post(ctport => play => "1 2 3");



( run in 2.214 seconds using v1.01-cache-2.11-cpan-5a3173703d6 )