[swift-users] Changing presence for MUC...

Kevin Smith kevin at kismith.co.uk
Fri Mar 2 20:27:47 CET 2012


On Fri, Mar 2, 2012 at 6:49 PM, Marc Neeley <neeleym at ociweb.com> wrote:
>  I thought that I would want presence to go to everything that I am
> connected to.

Sending it through the PresenceSender is the thing to do, then.

>  I guess I'm either in the room or not with a given MUC
> instance. When I join with a joinAs(...),  shouldn't a .onJoinComplete()
> callback be triggered?

There's three possible outcomes - onJoinComplete for a successful
join, onJoinFailed for an authoritative failure to join, or neither
while Swiften's waiting for the server to tell it one way or the
other. It's not immediately obvious to me what it's not triggering for
you - before I start blaming it on buggy MUC servers, it'd probably be
good to check this isn't a problem with our code - can you send the
protocol transcript for the session, please?

> I was assuming that joinAs() was asynchronous like
> connect() is for a client session and that .onJoinComplete() would be
> analogous to .onConnected().

You assumed correctly.

> After joining, I wanted the bot that I'm
> working on to send a few messages after joining.
>
> I have a new client session called XMPPclient_ and in the onConnected()
> handle I join the room:

I think you want to join the MUC through the MUCManager exposed on
Client::getMUCManager(). This will sort out the DirectedPresenceSender
for you.

> void MessageEngineComponent::handleJoinComplete(const std::string& nick) {
>
>        if (verbose_) {
>                std::cout << "Join complete for:" << nick << std::endl;
>        }
>
>        joined_ = true;
>
>        boost::shared_ptr<Swift::Message> xmppMsg(new Swift::Message());
>        xmppMsg->setType(Swift::Message::Type::Groupchat);
>        xmppMsg->setTo(localRoom_);
>        xmppMsg->setFrom(XMPPclient_->getJID());

If you're writing a client (or a bot, or whatever) you don't want to
be setting the from attribute on stanzas, not that this will break
what you're doing. Probably.

> The above code doesn't seem to fire. Did do the bind incorrectly or am I
> misinterpreting what .onJoinComplete() is?

I suspect something else is at play. Let's see the XML and go from there.

/K


More information about the swift-users mailing list