diff options
Diffstat (limited to 'src/xmpp/xmpp_component.hpp')
-rw-r--r-- | src/xmpp/xmpp_component.hpp | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/src/xmpp/xmpp_component.hpp b/src/xmpp/xmpp_component.hpp index 464ecaa..725b495 100644 --- a/src/xmpp/xmpp_component.hpp +++ b/src/xmpp/xmpp_component.hpp @@ -1,13 +1,13 @@ #ifndef XMPP_COMPONENT_INCLUDED # define XMPP_COMPONENT_INCLUDED -#include <string> - #include <network/socket_handler.hpp> - #include <xmpp/xmpp_parser.hpp> +#include <bridge/bridge.hpp> #include <unordered_map> +#include <memory> +#include <string> /** * An XMPP component, communicating with an XMPP server using the protocole @@ -55,13 +55,35 @@ public: * Send the closing signal for our document (not closing the connection though). */ void close_document(); - + /** + * Send a message from from@served_hostname, with the given body + */ + void send_message(const std::string& from, const std::string& body, const std::string& to); + /** + * Send a join from a new participant + */ + void send_user_join(const std::string& from, const std::string& nick, const std::string& to); + /** + * Send the self join to the user + */ + void send_self_join(const std::string& from, const std::string& nick, const std::string& to); + /** + * Send the MUC topic to the user + */ + void send_topic(const std::string& from, const std::string& topic, const std::string& to); /** * Handle the various stanza types */ void handle_handshake(const Stanza& stanza); + void handle_presence(const Stanza& stanza); private: + /** + * Return the bridge associated with the given full JID. Create a new one + * if none already exist. + */ + Bridge* get_user_bridge(const std::string& user_jid); + XmppParser parser; std::string stream_id; std::string served_hostname; @@ -70,6 +92,12 @@ private: std::unordered_map<std::string, std::function<void(const Stanza&)>> stanza_handlers; + /** + * One bridge for each user of the component. Indexed by the user's full + * jid + */ + std::unordered_map<std::string, std::unique_ptr<Bridge>> bridges; + XmppComponent(const XmppComponent&) = delete; XmppComponent(XmppComponent&&) = delete; XmppComponent& operator=(const XmppComponent&) = delete; |