我有 gloox 机器人。我正在尝试创建 MUC 房间处理程序,但现在我在 gcc 下编译时出错了。
class MucHandler : public MUCRoomHandler {
private:
Client *client;
public:
MucHandler(Client *cl){
client = cl;
}
virtual void handleMUCMessage (MUCRoom *room, const Message &msg, bool priv){
}
virtual bool handleMUCRoomCreation( MUCRoom *room )
{
}
virtual void handleMUCSubject( MUCRoom * /*room*/, const std::string& nick, const std::string& subject )
{
}
virtual void handleMUCInviteDecline(MUCRoom*, const JID& invitee, const string& reason){
}
virtual void handleMUCError(MUCRoom*, StanzaError error ){
}
virtual void handleMUCInfo( MUCRoom * /*room*/, int features, const std::string& name, const DataForm* infoForm )
{
}
virtual void handleMUCItems( MUCRoom * /*room*/, const Disco::ItemList& items )
{
}
virtual void handleMUCParticipantPresence(MUCRoom * room, const MUCRoomParticipant participant,Presence presence){
}
};
class Bot {
private:
Client *client;
MUCRoom *room;
MucHandler *muc;
public:
Bot(string login, string password, string resource){
const string fullJidName = login + '/' + resource;
JID jid(fullJidName);
//mucroom
const string server = "conference.jabber.ru";
const string uName = jid.username();
const string roomJid = uName + "@" + server + "/" + uName;
JID roomJID( roomJid );
client = new Client(jid,password);
client->setPresence( Presence::Available, -1 );
//mucRoom handler
muc = new MucHandler(client);
room = new MUCRoom( client, roomJID, muc, 0 );
//room->registerMUCRoomHandler(muc);
//
client->connect();
}
~Bot(){
delete client;
delete room;
}
void joinRoom(){
room->join();
room->getRoomInfo();
room->getRoomItems();
}
void setRoomNick(const string& nick){
room->setNick(nick);
}
void invite(const string& inv, const string& reason)
{
JID invitee(inv);
room->invite(invitee, reason);
}
};
int main(int argv, char** argc){
Bot bot("example3@gmail.com","example3","home");
}
但我有错误
无法分配抽象类型“Muchandler”的对象,因为以下虚函数在“MucHandler”/usr/include/gloox/mucroomhandler.h:107 中是纯的:note virtual void gloox::MUCRoomHandler::handlerMUCParticipantPresence(gloox::MUCRoom* , gloox::MUCRoomParticipant, const gloox::Presence&)
我不知道如何解决它。有谁能够帮助我?