diff options
Diffstat (limited to 'include/uplink.h')
-rw-r--r-- | include/uplink.h | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/include/uplink.h b/include/uplink.h index 993ab9ba1..924c05cfc 100644 --- a/include/uplink.h +++ b/include/uplink.h @@ -9,45 +9,53 @@ * Based on the original code of Services by Andy Church. */ -#ifndef UPLINK_H -#define UPLINK_H +#pragma once #include "sockets.h" #include "protocol.h" +#include "servers.h" namespace Uplink { extern void Connect(); + extern CoreExport void SendInternal(const Anope::map<Anope::string> &, const MessageSource &, const Anope::string &, const std::vector<Anope::string> &); + + template<typename... Args> + void Send(const Anope::map<Anope::string> &tags, const MessageSource &source, const Anope::string &command, Args &&...args) + { + SendInternal(tags, source, command, { Anope::ToString(args)... }); + } + + template<typename... Args> + void Send(const Anope::map<Anope::string> &tags, const Anope::string &command, Args &&...args) + { + SendInternal(tags, Me, command, { Anope::ToString(args)... }); + } + + template<typename... Args> + void Send(const MessageSource &source, const Anope::string &command, Args &&...args) + { + SendInternal({}, source, command, { Anope::ToString(args)... }); + } + + template<typename... Args> + void Send(const Anope::string &command, Args &&...args) + { + SendInternal({}, Me, command, { Anope::ToString(args)... }); + } } /* This is the socket to our uplink */ -class UplinkSocket : public ConnectionSocket, public BufferedSocket +class UplinkSocket final + : public ConnectionSocket + , public BufferedSocket { - public: +public: bool error; UplinkSocket(); ~UplinkSocket(); - bool ProcessRead() anope_override; - void OnConnect() anope_override; - void OnError(const Anope::string &) anope_override; - - /* A message sent over the uplink socket */ - class CoreExport Message - { - MessageSource source; - std::stringstream buffer; - - public: - Message(); - Message(const MessageSource &); - ~Message(); - template<typename T> Message &operator<<(const T &val) - { - this->buffer << val; - return *this; - } - }; + bool ProcessRead() override; + void OnConnect() override; + void OnError(const Anope::string &) override; }; extern CoreExport UplinkSocket *UplinkSock; - -#endif // UPLINK_H |