Subject: | MessageSend does not work with Net::XMPP::Message |
I had problems sending a message by passing a Net::XMPP::Message object
to the MessageSend() function in Protocol.pm. Sending a message by
passing the arguments directly to MessageSend(), however, worked:
executing
$Connection->Connect(...);
...
$Connection->MessageSend('to' -> 'user@server',
'body' -> 'my message');
works fine, but
$Connection->Connect(...);
...
my $chatMessage = Net::XMPP::Message->new();
$chatMessage->SetMessage('to' -> 'user@server',
'body' -> 'my message');
$Connection->MessageSend($chatMessage);
did not send anything. I think the problem in the MessageSend function
in Protocol.pm is that $mess is constructed by executing "$mess =
$self->_message();" and "$mess->SetMessage(@_);" although the message is
already constructed and ready to be sent.
I altered the function to:
--- MessageSend-new in Net/XMPP/Protocol.pm ---
sub MessageSend
{
my $self = shift;
my $mess;
if(ref($_[0]) eq "") {
$mess = $self->_message();
$mess->SetMessage(@_);
} else {
$mess = shift;
}
$self->Send($mess);
}
--- end of MessageSend-new ---
this works, but I cannot estimate how clean or dirty that is :)
P.S.:
my system (although I don't think this is important):
distribution name: Net::XMPP 1.0
perl version: 5.8.8
uname -a: Linux mms2 2.6.17 #1 SMP PREEMPT Wed Aug 30 17:44:42 CEST 2006
i686 GNU/Linux