queue up announces if not connected.
authorKevron Rees <tripzero.kev@gmail.com>
Sun, 18 Aug 2013 04:41:06 +0000 (21:41 -0700)
committerKevron Rees <tripzero.kev@gmail.com>
Sun, 18 Aug 2013 04:41:06 +0000 (21:41 -0700)
plugins/bluemonkey/irccoms.cpp
plugins/bluemonkey/irccoms.h

index 53c91c6..1450c27 100644 (file)
@@ -20,6 +20,7 @@ IrcCommunication::IrcCommunication(std::map<std::string, std::string> config, QO
        QObject::connect(session, &IrcSession::connected, [this](){
                connectedChanged();
                connected();
+               announceDequeue();
        });
 
        QObject::connect(session, &IrcSession::disconnected, [this](){
@@ -59,8 +60,23 @@ bool IrcCommunication::isConnected()
        return session->isConnected();
 }
 
+void IrcCommunication::announceDequeue()
+{
+       foreach(QString s, announceQueue)
+       {
+               announce(s);
+       }
+       announceQueue.clear();
+}
+
 void IrcCommunication::announce(QString s)
 {
+       if(!isConnected())
+       {
+               announceQueue.append(s);
+               return;
+       }
+
        qDebug()<<"channels: "<<mChannels;
        foreach(QString channel, mChannels)
        {
index 26f2a7f..20f1994 100644 (file)
@@ -20,6 +20,7 @@ public:
        void setChannels(QStringList c) { mChannels = c; }
 
        bool isConnected();
+       void announceDequeue();
 
 public Q_SLOTS:
        void respond(QString target, QString msg);
@@ -45,6 +46,7 @@ Q_SIGNALS:
 
 private:
        bool mSsl;
+       QStringList announceQueue;
        QStringList mChannels;
        IrcSession *session;
 };