Some more thoughts

This commit is contained in:
Blue 2025-03-03 21:36:02 +02:00
parent b997972ec1
commit bc2dc9bf07
Signed by: blue
GPG key ID: 9B203B252A63EE38
18 changed files with 146 additions and 42 deletions

View file

@ -5,7 +5,8 @@
#include <iostream>
Message::Message(const std::shared_ptr<Config>& config, const std::shared_ptr<gloox::Client>& client):
Message::Message(const std::shared_ptr<Config>& config, const std::shared_ptr<gloox::Client>& client, const Callback& callback):
callback(callback),
config(config),
client(client)
{

View file

@ -3,7 +3,9 @@
#pragma once
#include <string>
#include <memory>
#include <functional>
#include <gloox/client.h>
#include <gloox/messagehandler.h>
@ -12,13 +14,17 @@
#include "component/config.h"
class Message : public gloox::MessageHandler {
private:
typedef std::function<void (const std::string&, const std::string&)> Callback;
public:
Message(const std::shared_ptr<Config>& config, const std::shared_ptr<gloox::Client>& client);
Message(const std::shared_ptr<Config>& config, const std::shared_ptr<gloox::Client>& client, const Callback& callback);
~Message();
void handleMessage(const gloox::Message& message, gloox::MessageSession* session = 0) override;
private:
Callback callback;
std::weak_ptr<Config> config;
std::weak_ptr<gloox::Client> client;
};