Pass known/compatible tags to clients

This commit is contained in:
J-P Nurmi
2015-07-12 11:37:27 +02:00
parent c17c8c022b
commit 8a7c79bb78
6 changed files with 53 additions and 5 deletions

View File

@@ -794,6 +794,36 @@ void CClient::PutClient(const CString& sLine) {
Write(sCopy + "\r\n");
}
void CClient::PutClient(const CMessage& Message)
{
CString sLine = Message.ToString(CMessage::ExcludeTags);
// TODO: introduce a module hook that gives control over the tags that are sent
MCString mssTags;
if (HasServerTime()) {
CString sServerTime = Message.GetTag("time");
if (!sServerTime.empty()) {
mssTags["time"] = sServerTime;
} else {
mssTags["time"] = CUtils::FormatServerTime(Message.GetTime());
}
}
if (HasBatch()) {
CString sBatch = Message.GetTag("batch");
if (!sBatch.empty()) {
mssTags["batch"] = sBatch;
}
}
if (!mssTags.empty()) {
CUtils::SetMessageTags(sLine, mssTags);
}
PutClient(sLine);
}
void CClient::PutStatusNotice(const CString& sLine) {
PutModNotice("status", sLine);
}