#90 Give read-only access to the current IRCMessage being parsed.

master
Tomatix 4 years ago
parent 12158d9f10
commit d2974336de
  1. 5
      IRCClient/IRCBase.cpp
  2. 3
      IRCClient/IRCBase.h
  3. 2
      IRCClient/IRCBasePriv.h
  4. 9
      IRCClient/Private/parseIncoming.cpp

@ -414,3 +414,8 @@ IRCError IRCBase::declineDCC(std::shared_ptr<DCC> /*dcc*/)
{
return IRCError::NetworkUnreachable;
}
const IRCMessage* IRCBase::getCurrentMessageRaw() const
{
return mp->currentMessage;
}

@ -10,6 +10,7 @@
#include "IRCError.h"
#include "IRCPrefix.h"
#include "IRCMessage.h"
#include <string>
#include <vector>
@ -117,6 +118,8 @@ public:
std::pair<std::shared_ptr<DCC>, IRCError> initiateDCC(const std::string& port); // Creates a DCC initiator (tcp server)
IRCError declineDCC(std::shared_ptr<DCC> dcc);
[[nodiscard]] const IRCMessage* getCurrentMessageRaw() const;
protected:
virtual void onConnected() {}
virtual void onConnectedWithSSLExceptions(const std::vector<IRCError>& codes) {}

@ -109,6 +109,8 @@ struct IRCBasePriv
std::string validPrivilegeModes; // ohv etc. Ordered by most significant first.
std::string validPrivilegeSymbols; // @%+ etc. Ordered by most significant first.
IRCMessage* currentMessage{ nullptr };
/*
* Various helper functions for the IRC client implementation.
*/

@ -16,7 +16,14 @@ void IRCBasePriv::parseIncoming(const std::string& line)
{
using namespace Command::IRC;
/*
* Do NOT EVER do an "early return" from this function.
* Make sure it always reaches the end!
* No throwing from any of the message handler functions either.
*/
IRCMessage ircmessage(IRCPrefix(hostname), line);
currentMessage = &ircmessage;
if constexpr (DumpReadData) {
std::cout << "[RCV] ";
@ -126,4 +133,6 @@ void IRCBasePriv::parseIncoming(const std::string& line)
else {
handleUnhandled(ircmessage);
}
currentMessage = nullptr;
}

Loading…
Cancel
Save