diff options
Diffstat (limited to 'include/uplink.h')
-rw-r--r-- | include/uplink.h | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/include/uplink.h b/include/uplink.h index 23c3fd2af..8cb8c8b20 100644 --- a/include/uplink.h +++ b/include/uplink.h @@ -1,16 +1,23 @@ /* + * Anope IRC Services * - * (C) 2003-2017 Anope Team - * Contact us at team@anope.org + * Copyright (C) 2012-2017 Anope Team <team@anope.org> * - * Please read COPYING and README for further details. + * This file is part of Anope. Anope is free software; you can + * redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software + * Foundation, version 2. * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see see <http://www.gnu.org/licenses/>. */ -#ifndef UPLINK_H -#define UPLINK_H +#pragma once #include "sockets.h" #include "protocol.h" @@ -18,6 +25,21 @@ namespace Uplink { extern void Connect(); + extern void SendMessage(IRCMessage &); + + template<typename... Args> + void Send(const MessageSource &source, const Anope::string &command, Args&&... args) + { + IRCMessage message(source, command, std::forward<Args>(args)...); + SendMessage(message); + } + + template<typename... Args> + void Send(const Anope::string &command, Args&&... args) + { + IRCMessage message(Me, command, std::forward<Args>(args)...); + SendMessage(message); + } } /* This is the socket to our uplink */ @@ -27,27 +49,10 @@ class UplinkSocket : public ConnectionSocket, public BufferedSocket 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 |