morgon has asked for the wisdom of the Perl Monks concerning the following question:
I can't figure out how to set a presence with Net::XMPP...
I have rapsody running on a Raspberry Pi and would like to implement a bot that I can send messages from my phone.
I can indeed send messages but I cannot make my bot become visible in my android app...
This is what I try:
The output (when no other client is connected) is:use strict; use Net::XMPP; use Data::Dumper; my $con = new Net::XMPP::Client(); my $status = $con->Connect( hostname => 'mh.com', connectiontype => 'tcpip', ); my @result = $con->AuthSend( hostname => 'mh.com', username => 'pi', password => 'pi' ); $con->PresenceSend(); $con->SetCallBacks( presence=>\&do_presence, message=>\&do_message, ); sub do_presence { my ($id, $presence) = @_; print "Presence\n"; print "From: ", $presence->GetFrom(), "\n"; print "Type: ", $presence->GetType(), "\n"; print "Status: ", $presence->GetStatus(), "\n"; } sub do_message { my($id, $msg)=@_; print "message: ", $msg->GetBody; } while(defined($con->Process())) { }
Actually this is enough to send messages to the bot but the Pi is shown as offline in my Android app.Presence From: pi@mh.com/9b568386-f5e3-46de-bb1d-22f2d861a94a Type: Status:
I assume the problem is the presence...
So when I change the SetPresence-call to this:
I get this:$con->PresenceSend( status => "doing nothing at all" );
So yeah, I can set the status, but what I want to do is set the type, so I try:Presence From: pi@mh.com/c577d4e2-c4b3-44b5-b044-d2e7e67b0172 Type: Status: doing nothing at all
But now I get:$con->PresenceSend( type => "available" );
So does anybody know how to set a presence of "available" with Net::XMPP?Presence From: Type: error Status:
Many thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Presence and Net::XMPP
by NetWallah (Canon) on Apr 20, 2016 at 03:35 UTC | |
by morgon (Priest) on Apr 20, 2016 at 21:14 UTC |