1package Net::Async::XMPP::Server;
2$Net::Async::XMPP::Server::VERSION = '0.003';
3use strict;
4use warnings;
5use parent qw(Net::Async::XMPP);
6
7=head1 NAME
8
9Net::Async::XMPP::Server - asynchronous XMPP server based on L<Protocol::XMPP> and L<IO::Async::Protocol::Stream>.
10
11=head1 VERSION
12
13version 0.002
14
15=head1 DESCRIPTION
16
17Provides XMPP client support under L<IO::Async>.
18
19See L<Protocol::XMPP> for more details on this implementation.
20
21=head1 METHODS
22
23=cut
24
25sub connect {
26	my $self = shift;
27	my %params = @_;
28
29# We either have a transport or information for the connection
30	unless($params{transport}) {
31		$self->_open_connection(%params);
32		return;
33	}
34
35	my $transport = delete $params{transport};
36	$self->configure(transport => $transport);
37
38	$self->write($self->xmpp->preamble);
39	$self;
40}
41
42sub _open_connection {
43	my $self = shift;
44	my %params = @_;
45
46	my $on_connected = delete $params{on_connected} or die "Expected 'on_connected' as a CODE ref";
47
48	$self->get_loop->connect(
49		%params,
50		socktype => 'stream',
51		on_stream => sub {
52			my ($stream) = @_;
53
54			$self->connect(
55				%params,
56				transport => $stream,
57				on_connected => $on_connected,
58			);
59		},
60	);
61	return;
62}
63
641;
65
66__END__
67
68=head1 AUTHOR
69
70Tom Molesworth <cpan@entitymodel.com>
71
72=head1 LICENSE
73
74Copyright Tom Molesworth 2010-2014. Licensed under the same terms as Perl itself.
75