Hi.
I'm trying to write simple GUI (wxWidgets) application which uses
gloox. Here is the code:
#include <gloox/client.h>
#include <gloox/messagehandler.h>
#include <gloox/connectionlistener.h>
#include <wx/wx.h>
using namespace gloox;
class test : public MessageHandler, ConnectionListener, public wxApp {
public:
bool OnInit();
void onConnect();
void onDisconnect(ConnectionError);
bool onTLSConnect(const CertInfo&);
void handleMessage(Stanza *);
wxFrame *frm;
Client *cl;
};
IMPLEMENT_APP(test);
bool test::OnInit()
{
frm = new wxFrame(NULL, -1, "Frame", wxDefaultPosition, *(new wxSize(600,
400)));
frm->Show(true);
JID jid("blabla@xxxxxxxxxx/Gaim");
cl = new Client(jid, "pass");
cl->registerMessageHandler(this);
cl->registerConnectionListener(this);
cl->setInitialPriority(5);
cl->setAutoPresence(true);
cl->connect(false);
return TRUE;
}
void test::onConnect() {
(new wxMessageDialog(frm, "Connect", "Msg",
wxOK))->ShowModal();
}
void test::onDisconnect(ConnectionError e) {
(new wxMessageDialog(frm, "Disconnect", "Msg",
wxOK))->ShowModal();
}
bool test::onTLSConnect(const CertInfo& info) {
return true;
}
void test::handleMessage(Stanza *stanza) {
Stanza *s = Stanza::createMessageStanza(stanza->from().full(), "hello world");
cl->send(s);
}
If I write "cl->connect(true)" I see "Connect" message and application
hangs! If I write "cl->connect(false)" application works fine but I
never receive neither "Connect" message nor "Disconnect".
What is wrong?
Regards,
Andreev Nikita.