|
pianod2
multisource multiuser scriptable networked music player
|
Contains and manages all the services/rooms. More...
#include <servicemanager.h>


Public Member Functions | |
| virtual const Parsnip::Parser::Definitions & | getParserDefinitions () override |
| Retrieve the parser definitions handled by the interpreter. More... | |
| ServiceManager () | |
| virtual | ~ServiceManager () |
| float | periodic (void) |
| Perform periodic duties, and determine when next ones are due. More... | |
| void | shutdown (bool immediate) |
| Request all services (rooms) close so pianod can shutdown. More... | |
| bool | flush (void) |
| Persist data before shutdown. More... | |
| void | event (WaitEvent::Type type, const void *detail=nullptr, RESPONSE_CODE message=S_OK) |
| Distribute an event to connections waiting on it. More... | |
| void | event (WaitEvent::Type type, RESPONSE_CODE message=S_OK) |
| void | broadcastUserActions (bool v) |
| Enable or disable announcing user actions to all connections. More... | |
| bool | broadcastingActions (void) |
| Check whether user actions are announced to all connections. More... | |
| void | broadcast (const ResponseGroup &messages) |
| Send a message to every user on all services/rooms. More... | |
| void | broadcast (const ResponseGroup &messages, User *target) |
| Send a message to one user on all services/rooms. More... | |
| void | broadcastEffectivePrivileges () |
| Broadcast privileges to all users. More... | |
| void | broadcastEffectivePrivileges (User *target) |
| Broadcast privileges to a user. More... | |
| PianodService * | createRoom (const std::string &name, const AudioSettings &audio, FB_SERVICE_OPTIONS &options) |
| Add a room name/service pair to our list. More... | |
| void | removeRoom (PianodService *service) |
| Remove a room. More... | |
| bool | userIsOnline (const User *user) |
| Determine if a user is authenticated an connected in any room. More... | |
Public Member Functions inherited from PianodInterpreter | |
| virtual void | registerInterpreter (PianodDispatcher &dispatcher) |
| Register the interpreter with a dispatcher. More... | |
| const HelpList | getHelp (const std::vector< std::string > &search, std::set< std::string > *option_parsers) |
| Search the interpreter's definitions for any definitions matching search criteria. More... | |
Static Public Member Functions | |
| static const Parsnip::Parser::Definitions & | parser_definitions () |
| static const PianodSchema::CommandIds & | json_request_names (PianodSchema &schema) |
| Retrieve names for our JSON requests, and make schema revisions. More... | |
Static Public Member Functions inherited from PianodInterpreter | |
| static bool | optionIs (const Parsnip::Data &options, const char *name, const char *expected) |
| Check if a string value exists and is case-blind equal to a particular value. More... | |
| template<typename ValueType , typename LookupType > | |
| static ValueType | optionalValue (const Parsnip::Data &options, const char *name, const LookupType &lookup, const ValueType default_value) |
| Retrieve the ID of a string value. More... | |
Public Attributes | |
| bool | broadcast_user_actions = false |
Private Member Functions | |
| virtual bool | authorizedCommand (Parsnip::Parser::CommandId command, PianodConnection &conn) override |
| Check whether a command is authorized. More... | |
| virtual ResponseCollector | handleCommand (Parsnip::Parser::CommandId command, const Parsnip::Data &options, PianodConnection &conn) override |
| Command handler. More... | |
| void | sendSourceReadyEvents (const Media::Source *const source, RESPONSE_CODE result) |
| Send events to those waiting on source ready, either a specific source, any source, or all sources. More... | |
| void | sourceReady (const Media::Source *const src) |
| Prepare for a new source by alerting auto engines of it. More... | |
| void | sourceOffline (const Media::Source *const src) |
| Handle a source going offline by removing it from use. More... | |
| void | sourceRemoved (const Media::Source *const src) |
| Handle a source being deleted. More... | |
Private Attributes | |
| const Parsnip::ParserRef | master_parser |
| A single parser shared by all rooms. More... | |
| const PianodSchemaRef | master_schema |
| A single schema shared by all rooms. More... | |
| PianodService * | master_service = nullptr |
| The initial room/service. More... | |
| bool | shutdown_pending = false |
| Set when shutdown initiated. More... | |
| time_t | startup_time = time (nullptr) |
| Time the service manager was instantiated. More... | |
Additional Inherited Members | |
Public Types inherited from PianodInterpreter | |
| using | HelpList = PianodDispatcher::HelpList |
Protected Types inherited from PianodInterpreter | |
| using | StringVector = std::vector< std::string > |
Static Protected Attributes inherited from PianodInterpreter | |
| static const Parsnip::Data | EmptyDictionary {Parsnip::Data::Dictionary} |
| An empty dictionary, often used as a default with Parsnip::Data::getOr. More... | |
| static const StringVector | EmptyStringVector |
| An empty string vector, often used as a default with Parsnip::Data::getOr. More... | |
Contains and manages all the services/rooms.
| ServiceManager::ServiceManager | ( | ) |

|
virtual |
|
overrideprivatevirtual |
Check whether a command is authorized.
| command_id | The command requesting execution. |
| context | Connection details, including authentication state and privileges. |
Implements PianodInterpreter.

| void ServiceManager::broadcast | ( | const ResponseGroup & | messages | ) |
Send a message to every user on all services/rooms.
| messages | The message(s) to broadcast. |


| void ServiceManager::broadcast | ( | const ResponseGroup & | messages, |
| User * | target | ||
| ) |
Send a message to one user on all services/rooms.
| messages | The messages to broadcast. |
| target | The user to send the message to. If nullptr, broadcasts to visitors. |

| void ServiceManager::broadcastEffectivePrivileges | ( | ) |
Broadcast privileges to all users.


| void ServiceManager::broadcastEffectivePrivileges | ( | User * | target | ) |
Broadcast privileges to a user.
| target | The target user, or NULL to target visitors. |

|
inline |
Check whether user actions are announced to all connections.

|
inline |
Enable or disable announcing user actions to all connections.
| v | True to enable, false to disable. |

| PianodService * ServiceManager::createRoom | ( | const std::string & | name, |
| const AudioSettings & | audio, | ||
| FB_SERVICE_OPTIONS & | options | ||
| ) |
| void ServiceManager::event | ( | WaitEvent::Type | type, |
| const void * | detail = nullptr, |
||
| RESPONSE_CODE | reply = S_OK |
||
| ) |
Distribute an event to connections waiting on it.
| type | The type of event. |
| detail | Pointer representing a specific event instance. |
| reply | Status code to report to connections waiting for the event. |

|
inline |
| bool ServiceManager::flush | ( | void | ) |
Persist data before shutdown.


|
overridevirtual |
Retrieve the parser definitions handled by the interpreter.
Implements PianodInterpreter.

|
overrideprivatevirtual |
Command handler.
| command_id | Command to execute. |
| parameters | Command parameters. |
| context | Connection details, including authentication state and privileges. |
| CommandError | or other exception if an error occurs. |
Implements PianodInterpreter.

|
static |
Retrieve names for our JSON requests, and make schema revisions.
| schema | The schemaset containing our requests. |


|
static |

| float ServiceManager::periodic | ( | void | ) |
Perform periodic duties, and determine when next ones are due.
All sources, the audio engines (rooms) and users are invoked, allowing them to perform periodic duties (freeing resources, persisting data, background tasks).


| void ServiceManager::removeRoom | ( | PianodService * | service | ) |
Remove a room.
Triggers a flush when the last room is removed. This is a callback function, invoked when Football calls the serviceShutdown() method.
| service | The room to remove. |


|
private |
Send events to those waiting on source ready, either a specific source, any source, or all sources.
| source | The source that is transitioning from pending to ready or dead. |
| result | The status of the source's transition. |


| void ServiceManager::shutdown | ( | bool | immediate | ) |
Request all services (rooms) close so pianod can shutdown.
| immediate | If true, aborts playback in all rooms. |


|
private |
Handle a source going offline by removing it from use.
Unlike invalidating sources, however, historical and queue references remain.


|
private |
Prepare for a new source by alerting auto engines of it.


|
private |
Handle a source being deleted.


| bool ServiceManager::userIsOnline | ( | const User * | user | ) |
Determine if a user is authenticated an connected in any room.
| user | The user to look for. |


| bool ServiceManager::broadcast_user_actions = false |
|
private |
A single parser shared by all rooms.
|
private |
A single schema shared by all rooms.
|
private |
The initial room/service.
|
private |
Set when shutdown initiated.
|
private |
Time the service manager was instantiated.