summaryrefslogtreecommitdiffstats
blob: ad1495ff928c4a5899d83329340e0d5b89c602b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "Swiften/Chat/ChatStateMessageSender.h"

#include <boost/bind.hpp>

#include "Swiften/Client/StanzaChannel.h"

namespace Swift {

ChatStateMessageSender::ChatStateMessageSender(ChatStateNotifier* notifier, StanzaChannel* stanzaChannel, const JID& contact) : contact_(contact) {
	notifier_ = notifier;
	stanzaChannel_ = stanzaChannel;
	notifier_->onChatStateChanged.connect(boost::bind(&ChatStateMessageSender::handleChatStateChanged, this, _1));
}

void ChatStateMessageSender::handleChatStateChanged(ChatState::ChatStateType state) {
	boost::shared_ptr<Message> message(new Message());
	message->setTo(contact_);
	message->addPayload(boost::shared_ptr<Payload>(new ChatState(state)));
	stanzaChannel_->sendMessage(message);
}

}