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

Marc Neeley neeleym at ociweb.com
Fri Mar 2 19:49:29 CET 2012


Kevin,
  I thought that I would want presence to go to everything that I am
connected to.  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?  I was assuming that joinAs() was asynchronous like
connect() is for a client session and that .onJoinComplete() would be
analogous to .onConnected().  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:

	Swift::DirectedPresenceSender* localDirectedPresenceSender_ = new
Swift::DirectedPresenceSender(XMPPclient_->getPresenceSender());
	XMPPMUChandle_ = new
Swift::MUC(XMPPclient_->getStanzaChannel(),XMPPclient_->getIQRouter(),localD
irectedPresenceSender_, localRoom_ ,XMPPclient_->getMUCRegistry());
	
XMPPMUChandle_->onJoinComplete.connect(boost::bind(&MessageEngineComponent::
handleJoinComplete,this,_1));
	XMPPMUChandle_->joinAs("EnterpriseMessenger");  

I see the bot join the room fine with a "EnterpriseMessenger entered the
room."  Statement showing up in another client who is in the room already.
Because I have done a bind in the above code, I want to set a variable and
then send a message:

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());
	xmppMsg->setBody("This is a new Multi-User message...");
	XMPPclient_->sendMessage(xmppMsg);
}

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

Thanks,
Marc

-----Original Message-----
From: k.i.smith at gmail.com [mailto:k.i.smith at gmail.com] On Behalf Of Kevin
Smith
Sent: Friday, March 02, 2012 1:48 AM
To: Marc Neeley
Cc: swift-users at swift.im
Subject: Re: [swift-users] Changing presence for MUC...

On Thu, Mar 1, 2012 at 7:04 PM, Marc Neeley <neeleym at ociweb.com> wrote:
> Is there a way to change the presence indication in Swift::MUC for a 
> connected client. I have successfully started a Client session and 
> have joined a MUC session, but I'm not clear how to change the MUC 
> presence state. This is a bot type of client and I don't want it to 
> drop the connection, but I would like it to give an indication of it's 
> state and/or presence status. Any thoughts would be appreciated.

Without checking the code, I believe using the Client::getPresenceSender
will get the presence sender for your session, and than sending broadcast
presence through this will also send it to all the MUC's you're in. Was that
what you want, or do you want unique presence for each room?

/K



More information about the swift-users mailing list