chore: Update message passing method in NotificationCenter
This commit is contained in:
@@ -10,6 +10,8 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/status/status.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace core {
|
namespace core {
|
||||||
@@ -26,7 +28,7 @@ struct Message {
|
|||||||
class IMessageListener {
|
class IMessageListener {
|
||||||
public:
|
public:
|
||||||
virtual ~IMessageListener() = default;
|
virtual ~IMessageListener() = default;
|
||||||
virtual void OnMessageReceived(const Message& message) = 0;
|
virtual absl::Status OnMessageReceived(const Message& message) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IMessageProtocol {
|
class IMessageProtocol {
|
||||||
@@ -108,6 +110,8 @@ class Reflectable {
|
|||||||
virtual std::any GetPropertyValue(const std::string& property_name) const = 0;
|
virtual std::any GetPropertyValue(const std::string& property_name) const = 0;
|
||||||
virtual void SetPropertyValue(const std::string& property_name,
|
virtual void SetPropertyValue(const std::string& property_name,
|
||||||
const std::any& value) = 0;
|
const std::any& value) = 0;
|
||||||
|
virtual std::any InvokeMethod(const std::string& method_name,
|
||||||
|
const std::vector<std::any>& args) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ObjectFactory {
|
class ObjectFactory {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class NotificationCenter {
|
|||||||
void PostNotification(const Notification& notification) {
|
void PostNotification(const Notification& notification) {
|
||||||
const auto& observerList = observers[notification.type];
|
const auto& observerList = observers[notification.type];
|
||||||
for (auto observer : observerList) {
|
for (auto observer : observerList) {
|
||||||
observer->onMessageReceived(notification);
|
observer->OnMessageReceived(notification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user