summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/modules/ircv3_batch.h10
-rw-r--r--src/modules/m_ircv3_batch.cpp9
2 files changed, 16 insertions, 3 deletions
diff --git a/include/modules/ircv3_batch.h b/include/modules/ircv3_batch.h
index 841554bdb..7708e8d01 100644
--- a/include/modules/ircv3_batch.h
+++ b/include/modules/ircv3_batch.h
@@ -89,6 +89,7 @@ class IRCv3::Batch::Batch
unsigned int bit;
BatchInfo* batchinfo;
ClientProtocol::Message* batchstartmsg;
+ ClientProtocol::Message* batchendmsg;
void Setup(unsigned int b)
{
@@ -158,6 +159,15 @@ class IRCv3::Batch::Batch
*/
ClientProtocol::Message& GetBatchStartMessage() { return *batchstartmsg; }
+ /** Get the batch end client protocol message.
+ * The returned message object can be manipulated to add extra parameters or labels to the message. The first
+ * parameter of the message is the batch reference tag generated by the module providing batch support.
+ * If the batch type string was specified, it will be the second parameter of the message.
+ * May only be called if IsRunning() == true.
+ * @return Mutable batch end client protocol message.
+ */
+ ClientProtocol::Message& GetBatchEndMessage() { return *batchendmsg; }
+
friend class ManagerImpl;
};
diff --git a/src/modules/m_ircv3_batch.cpp b/src/modules/m_ircv3_batch.cpp
index df2b00f49..91ff0b140 100644
--- a/src/modules/m_ircv3_batch.cpp
+++ b/src/modules/m_ircv3_batch.cpp
@@ -44,10 +44,14 @@ struct IRCv3::Batch::BatchInfo
std::vector<LocalUser*> users;
BatchMessage startmsg;
ClientProtocol::Event startevent;
+ BatchMessage endmsg;
+ ClientProtocol::Event endevent;
BatchInfo(ClientProtocol::EventProvider& protoevprov, IRCv3::Batch::Batch& b)
: startmsg(b, true)
, startevent(protoevprov, startmsg)
+ , endmsg(b, false)
+ , endevent(protoevprov, endmsg)
{
}
};
@@ -151,6 +155,7 @@ class IRCv3::Batch::ManagerImpl : public Manager
batch.manager = this;
batch.batchinfo = new IRCv3::Batch::BatchInfo(protoevprov, batch);
batch.batchstartmsg = &batch.batchinfo->startmsg;
+ batch.batchendmsg = &batch.batchinfo->endmsg;
active_batches.push_back(&batch);
}
@@ -164,12 +169,10 @@ class IRCv3::Batch::ManagerImpl : public Manager
BatchInfo& batchinfo = *batch.batchinfo;
// Send end batch message to all users who got the batch start message and unset bit so it can be reused
- BatchMessage endbatchmsg(batch, false);
- ClientProtocol::Event endbatchevent(protoevprov, endbatchmsg);
for (std::vector<LocalUser*>::const_iterator i = batchinfo.users.begin(); i != batchinfo.users.end(); ++i)
{
LocalUser* const user = *i;
- user->Send(endbatchevent);
+ user->Send(batchinfo.endevent);
batchbits.set(user, batchbits.get(user) & ~batch.GetBit());
}