Skip to content

Commit

Permalink
Sending notification about state change
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthick-Somasundaresan committed Aug 22, 2024
1 parent 95ab147 commit e918bec
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
30 changes: 30 additions & 0 deletions WebServer/WebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ namespace Plugin {
message = _T("WebServer Couldnt get StateControl.");

} else {
stateControl->Register(&_notification);
uint32_t result = stateControl->Configure(_service);
stateControl->Release();
if (result != Core::ERROR_NONE) {
Expand Down Expand Up @@ -163,5 +164,34 @@ namespace Plugin {
Core::IWorkerPool::Instance().Submit(PluginHost::IShell::Job::Create(_service, PluginHost::IShell::DEACTIVATED, PluginHost::IShell::FAILURE));
}
}
void WebServer::StateChange(const PluginHost::IStateControl::state state)
{
switch (state) {
case PluginHost::IStateControl::RESUMED:
TRACE(Trace::Information,
(string(_T("StateChange: { \"suspend\":false }"))));
_service->Notify("{ \"suspended\":false }");
break;
case PluginHost::IStateControl::SUSPENDED:
TRACE(Trace::Information,
(string(_T("StateChange: { \"suspend\":true }"))));
_service->Notify("{ \"suspended\":true }");
break;
case PluginHost::IStateControl::EXITED:
Core::IWorkerPool::Instance().Submit(
PluginHost::IShell::Job::Create(_service,
PluginHost::IShell::DEACTIVATED,
PluginHost::IShell::REQUESTED));
break;
case PluginHost::IStateControl::UNINITIALIZED:
break;
default:
ASSERT(false);
break;
}
}



}
}
3 changes: 0 additions & 3 deletions WebServer/WebServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ POP_WARNING()
string Information() const override;

void StateChange(PluginHost::IStateControl::state);



private:
void Deactivated(RPC::IRemoteConnection* connection);

Expand Down
8 changes: 0 additions & 8 deletions WebServer/WebServerImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,6 @@ POP_WARNING()
}


//void RequestForStateChange(const PluginHost::IStateControl::command command) {
void Dispatch() {
bool stateChanged = false;
uint32_t result = Core::ERROR_NONE;
Expand Down Expand Up @@ -777,13 +776,6 @@ POP_WARNING()
_requestedCommand = command;
_job.Submit();
_adminLock.Unlock();
/*if (_state == PluginHost::IStateControl::UNINITIALIZED ||
(_state == PluginHost::IStateControl::RESUMED && command == PluginHost::IStateControl::SUSPEND) ||
(_state == PluginHost::IStateControl::SUSPENDED && command == PluginHost::IStateControl::RESUME)){
Core::ProxyType<Core::IDispatch> job = Core::ProxyType<Core::IDispatch>(Core::ProxyType<StateRequestHandler>::Create(*this, command));
Core::WorkerPool::Instance().Submit(job);
}
*/
return (Core::ERROR_NONE);
}

Expand Down

0 comments on commit e918bec

Please sign in to comment.