1package DJabberd::ClusterMessage::DeliverStanza; 2use strict; 3use warnings; 4use base 'DJabberd::ClusterMessage'; 5use fields ('to', # bare JID to deliver it to 6 'asxml', # string representing the XML to send 7 ); 8 9sub new { 10 my $self = shift; # instance or class 11 $self = fields::new($self) unless ref $self; 12 13 my ($jid, $stanza) = @_; 14 $self->{to} = $jid->as_bare_string; 15 $self->{asxml} = $stanza; # TODO: ->as_xml, don't take raw object. or both? 16 return $self; 17} 18 19sub process { 20 my ($self, $vhost) = @_; 21 my @dconns = grep { $_->is_available } $vhost->find_conns_of_bare(DJabberd::JID->new($self->{to})); 22 23 warn "Sending stanza to @dconns: [$self->{asxml}]\n"; 24 foreach my $c (@dconns) { 25 $c->write(\ $self->{asxml}); 26 } 27} 28 291; 30