Skip to content

Commit

Permalink
Development/last bits (#1671)
Browse files Browse the repository at this point in the history
* [PRUNING] Cleanup of the "all" event mechanism sending out RESTFULL notifications and JSONRPC events.

* [SYNC] Update after testing..

* [ALL] Align the "All" notifications to the basics and nothing more.

* Update PluginServer.cpp

Aligning the enums to the latest discussions
  • Loading branch information
pwielders authored Jun 27, 2024
1 parent a53cd99 commit bfaabd5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
19 changes: 15 additions & 4 deletions Source/Thunder/PluginServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,11 @@ namespace PluginHost {
Notify(EMPTY_STRING, string(_T("{\"state\":\"activated\",\"reason\":\"")) + textReason.Data() + _T("\"}"));

Unlock();

#ifdef THUNDER_RESTFULL_API
Notify(EMPTY_STRING, string(_T("{\"state\":\"activated\",\"reason\":\"")) + textReason.Data() + _T("\"}"));
#endif
Notify(_T("statechange"), string(_T("{\"state\":\"activated\",\"reason\":\"")) + textReason.Data() + _T("\"}"));
}
}
} else {
Expand Down Expand Up @@ -604,7 +609,10 @@ namespace PluginHost {
if (currentState != IShell::state::ACTIVATION) {
SYSLOG(Logging::Shutdown, (_T("Deactivated plugin [%s]:[%s]"), className.c_str(), callSign.c_str()));

#ifdef THUNDER_RESTFULL_API
Notify(EMPTY_STRING, string(_T("{\"state\":\"deactivated\",\"reason\":\"")) + textReason.Data() + _T("\"}"));
#endif
Notify(_T("statechange"), string(_T("{\"state\":\"deactivated\",\"reason\":\"")) + textReason.Data() + _T("\"}"));
}
}

Expand Down Expand Up @@ -690,7 +698,12 @@ namespace PluginHost {
State(UNAVAILABLE);
_administrator.Unavailable(callSign, this);

Unlock();

#ifdef THUNDER_RESTFULL_API
Notify(EMPTY_STRING, string(_T("{\"state\":\"unavailable\",\"reason\":\"")) + textReason.Data() + _T("\"}"));
#endif
Notify(_T("statechange"), string(_T("{\"state\":\"unavailable\",\"reason\":\"")) + textReason.Data() + _T("\"}"));
}

Unlock();
Expand Down Expand Up @@ -1200,10 +1213,8 @@ namespace PluginHost {
ASSERT(callsign.empty() == false);

if (jsonrpc_event.empty() == false) {
JsonData::Events::ForwardEventParamsData message;
message.Data = Exchange::Controller::IEvents::INotification::Event({ jsonrpc_event, parameters });
message.Callsign = callsign;
Exchange::Controller::JEvents::Event::ForwardEvent(*controller, message);
JsonData::Events::ForwardMessageParamsData::EventData message({ jsonrpc_event, parameters, callsign });
controller->Notify(_T("all"), message);
}
else {
string messageString = string(_T("{\"callsign\":\"")) + callsign + _T("\", {\"data\":\"") + parameters + _T("\"}}");
Expand Down
18 changes: 8 additions & 10 deletions Source/plugins/IController.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,25 +196,23 @@ namespace Controller {
struct EXTERNAL IEvents : virtual public Core::IUnknown {
enum { ID = RPC::ID_CONTROLLER_EVENTS };

struct Event {
string Event;
string Params /* @opaque @optional */;
string CallSign /* @optional */;
};

// @event
struct EXTERNAL INotification : virtual public Core::IUnknown {
enum { ID = RPC::ID_CONTROLLER_EVENTS_NOTIFICATION };

struct Event {
string event;
string params /* @opaque @optional */;
};

// @text all
// @brief Notifies all events forwarded by the framework
// @details The Controller plugin is an aggregator of all the events triggered by a specific plugin.
// All notifications send by any plugin are forwarded over the Controller socket as an event.
// @param callsign: Origin of the message
// @param data: Contents of the message
virtual void ForwardMessage(const string& callsign, const string& data /* @opaque */) = 0;

// @text all
virtual void ForwardEvent(const string& callsign, const Event& data) = 0;
virtual void ForwardMessage(const Event& data) = 0;
};
};

Expand Down Expand Up @@ -317,7 +315,7 @@ namespace Controller {
// @property @alt:deprecated status
// @brief Services metadata
// @details If callsign is omitted, metadata of all services is returned.
virtual Core::hresult Services(const string& callsign /* @index @optional */, Data::IServicesIterator*& services /* @out @extract */) const = 0;
virtual Core::hresult Services(const string& callsign /* @optional @index */, Data::IServicesIterator*& services /* @out @extract */) const = 0;

// @property
// @brief Connections list
Expand Down
6 changes: 0 additions & 6 deletions Source/plugins/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ namespace PluginHost
Add(_T("processedrequests"), &ProcessedRequests);
Add(_T("processedobjects"), &ProcessedObjects);
#endif
#if THUNDER_RESTFULL_API
Add(_T("observers"), &Observers);
#endif
Add(_T("module"), &Module);
Add(_T("version"), &ServiceVersion);

Expand All @@ -159,9 +157,7 @@ namespace PluginHost
, ProcessedRequests(copy.ProcessedRequests)
, ProcessedObjects(copy.ProcessedObjects)
#endif
#if THUNDER_RESTFULL_API
, Observers(copy.Observers)
#endif
, ServiceVersion(copy.ServiceVersion)
, Module(copy.Module)
, InterfaceVersion(copy.InterfaceVersion)
Expand All @@ -171,9 +167,7 @@ namespace PluginHost
Add(_T("processedrequests"), &ProcessedRequests);
Add(_T("processedobjects"), &ProcessedObjects);
#endif
#if THUNDER_RESTFULL_API
Add(_T("observers"), &Observers);
#endif
Add(_T("module"), &Module);
Add(_T("version"), &ServiceVersion);

Expand Down
2 changes: 0 additions & 2 deletions Source/plugins/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ namespace PluginHost {
Core::JSON::DecUInt32 ProcessedRequests;
Core::JSON::DecUInt32 ProcessedObjects;
#endif
#if THUNDER_RESTFULL_API
Core::JSON::DecUInt32 Observers;
#endif
Version ServiceVersion;
Core::JSON::String Module;
Core::JSON::ArrayType<Core::JSON::String> InterfaceVersion;
Expand Down
1 change: 0 additions & 1 deletion Source/plugins/Service.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@ namespace PluginHost {
{
_errorMessage = message;
}

#if THUNDER_RUNTIME_STATISTICS
inline void IncrementProcessedRequests()
{
Expand Down

0 comments on commit bfaabd5

Please sign in to comment.