Hello App: mgmtHello.cpp
Contents
mgmtHello.cpp
/*
* mgmtHello.cpp - handle a management request sent by supervisor for the hello channel
*
* Copyright (c) 2024 HanoverSoft
* Written by Anthony V. Edwards
* 820 Churchill Drive, Chapel Hill, NC 27517
* ave@hanoversoft.net
*
* While the Hello app is running, the Supervisor app can query its state,
* collect metrics, and possibly adjust some parameters. This is done here
* through the MgmtClient class interface, which is part of MAE.
*/
#include <MAE.h>
#include "hello.h"
// Variables from cache.cpp
extern string CacheList; // the list of parameter categories
extern int HelloCache_max; // the maximum size of the session cache
/** Get dynamic values
* @return number of active HelloApp records in cache
*/
{
int size= HelloCache.activeRecords();
return (string) "" + size;
}
/** Set new values
* @param param - key/value pairs of variables to set; however, only "value" is supported
*/
{
int newSize= param.getInt("value");
// compress the array - get rid of gaps
HelloCache.optimize();
// Resize as instructed
HelloCache.setSize(newSize);
return true;
}
/** When an admin user has a privileged UI interface, this method will handle the UI event.
* Note: When UI controls require a callback, make sure cbdata["sysadmin"]="T" so the
* MgmtClient::handleInputResponse() is called instead of the app's.
* @param device - the connection back to the user's device
* @param param - key/value pairs to handle a UI response
*/
{
}
/** When an operator user has a privileged UI interface, this method will handle the UI event.
* Note: When UI controls require a callback, make sure cbdata["sysadmin"]="T" so our
* MgmtClient::handleInputResponse() is called instead of the app's.
* @param device - the connection back to the user's device
* @param param - key/value pairs to handle a UI response
*/
{
}
/** Handle user interactions for the admin or operator user.
* @param device - the connection back to the user's device
* @param cbtag - callback tag / action to take
* @param cbdata - callback data associated with action
* @param response - user selection or text input
*/
{
// Note: we don't have an admin or operator special interface, so just
// route it back to the app's input response handler.
MAE::handleInputResponse(MAE::getAppId(), device, cbtag, cbdata, response);
}
/** Initialize our management parameters that can be get & set by supervisor.
* @param channel - the channel name to initialize (relevant if the app supports muiltiple channels)
*/
{
// GET parameters - Values that can be queried
addGetParameter ("", "appname", MAE::getName()); // our name
addGetParameter ("cache", "list", CacheList); // list of categories to query; for each item in list, there's *_max, *_size
addGetParameter ("cache", "User_size", &getHelloCacheSize); // the number of active sessions
addGetParameter ("cache", "User_max", &HelloCache_max); // the maximum number of active sessions allowed
// SET parameters - Values that can be changed
addSetParameter ("cache", "User_max", &setHelloCacheSize); // change the maximum number of active sessions allowed
}