Sending XMPP message to offline Google Talk user with ruby xmpp4r

1.2k views Asked by At

When using Perl's Net::Jabber, sending a simple message to an offline user causes the message to be delivered to the user when he comes online (it even show's in the user's gmail account as unread messages). That's as simple as doing

my $msg = Net::Jabber::Message->new();
$msg->SetMessage(...);
$connection->Send($msg);

In Ruby xmpp4r, doing the same equivalent thing does not send the message to an offline user, instead returning (async) a xmpp service-unavailable stanza or even not returning anything, and also not working. Message is simply lost.

How can one send an offline message with xmpp4r?

Also, in related subject, in xmpp's api docs for Jabber::Stream's send method, there is a "block" parameter. How does one use that?

Thanks

1

There are 1 answers

1
Joe Hildebrand On BEST ANSWER

Make sure that you're doing type=:chat on the message.

client.send(Jabber::Message.new(jid, contents).set_type(:chat))

(code copied from Ricardo Pardini's comment, for long-term clarity)