obs-websocket/src/eventhandler/EventHandler_Config.cpp

146 lines
4.2 KiB
C++
Raw Normal View History

2021-11-20 01:32:22 +00:00
/*
obs-websocket
Copyright (C) 2016-2021 Stephane Lepin <stephane.lepin@gmail.com>
Copyright (C) 2020-2021 Kyle Manning <tt2468@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <https://www.gnu.org/licenses/>
*/
2021-05-14 02:11:19 +00:00
#include "EventHandler.h"
docs: Overhaul documentation (#863) More docs-related commits will follow, but this needs to be merged in order to continue with other development. * Docs: Overhaul docs generator (beginning) * docs: Rename comments file * docs: Move comments gitignore * docs: Initial request documentation * docs: Improvements to comment processing * docs: More improvements * docs: Add enum functionality for protocol.json * WebSocketServer: Document enums * RequestHandler: Document RequestStatus enum * Base: Move ObsWebSocketRequestBatchExecutionType to its own file Moves it to its own file, renaming it to `RequestBatchExecutionType`. Changes the RPC to use integer values for selecting execution type instead of strings. * docs: Update introduction header Removes the enum section, and documents RequestBatchExecutionType. * WebSocketCloseCode: Shuffle a bit * Base: Use `field` instead of `key` or `parameter` in most places * RequestStatus: Mild shuffle It was really bothering me that OutputPaused and OutputNotPaused had to be separated, so we're breaking it while we're breaking other stuff. * docs: Delete old files They may be added back in some form, but for now I'm getting them out of the way. * docs: Add enum identifier value Forgot to add this before, oops * docs: Document more enums * docs: Add basic protocol.md generator * docs: More work on MD generator * docs: MD generator should be finished now * docs: More fixes * docs: More fixes * docs: More tweaks + add readme * docs: Update readme and add inputs docs * docs: More documentation
2021-12-11 05:38:18 +00:00
/**
* The current scene collection has begun changing.
*
* Note: We recommend using this event to trigger a pause of all polling requests, as performing any requests during a
* scene collection change is considered undefined behavior and can cause crashes!
*
* @dataField sceneCollectionName | String | Name of the current scene collection
*
* @eventType CurrentSceneCollectionChanging
* @eventSubscription Config
* @complexity 1
* @rpcVersion -1
* @initialVersion 5.0.0
* @category config
* @api events
*/
void EventHandler::HandleCurrentSceneCollectionChanging()
{
json eventData;
eventData["sceneCollectionName"] = Utils::Obs::StringHelper::GetCurrentSceneCollection();
BroadcastEvent(EventSubscription::Config, "CurrentSceneCollectionChanging", eventData);
}
docs: Overhaul documentation (#863) More docs-related commits will follow, but this needs to be merged in order to continue with other development. * Docs: Overhaul docs generator (beginning) * docs: Rename comments file * docs: Move comments gitignore * docs: Initial request documentation * docs: Improvements to comment processing * docs: More improvements * docs: Add enum functionality for protocol.json * WebSocketServer: Document enums * RequestHandler: Document RequestStatus enum * Base: Move ObsWebSocketRequestBatchExecutionType to its own file Moves it to its own file, renaming it to `RequestBatchExecutionType`. Changes the RPC to use integer values for selecting execution type instead of strings. * docs: Update introduction header Removes the enum section, and documents RequestBatchExecutionType. * WebSocketCloseCode: Shuffle a bit * Base: Use `field` instead of `key` or `parameter` in most places * RequestStatus: Mild shuffle It was really bothering me that OutputPaused and OutputNotPaused had to be separated, so we're breaking it while we're breaking other stuff. * docs: Delete old files They may be added back in some form, but for now I'm getting them out of the way. * docs: Add enum identifier value Forgot to add this before, oops * docs: Document more enums * docs: Add basic protocol.md generator * docs: More work on MD generator * docs: MD generator should be finished now * docs: More fixes * docs: More fixes * docs: More tweaks + add readme * docs: Update readme and add inputs docs * docs: More documentation
2021-12-11 05:38:18 +00:00
/**
* The current scene collection has changed.
*
* Note: If polling has been paused during `CurrentSceneCollectionChanging`, this is the que to restart polling.
*
* @dataField sceneCollectionName | String | Name of the new scene collection
*
* @eventType CurrentSceneCollectionChanged
* @eventSubscription Config
* @complexity 1
* @rpcVersion -1
* @initialVersion 5.0.0
* @category config
* @api events
*/
2021-05-14 02:11:19 +00:00
void EventHandler::HandleCurrentSceneCollectionChanged()
{
json eventData;
eventData["sceneCollectionName"] = Utils::Obs::StringHelper::GetCurrentSceneCollection();
BroadcastEvent(EventSubscription::Config, "CurrentSceneCollectionChanged", eventData);
2021-05-14 02:11:19 +00:00
}
docs: Overhaul documentation (#863) More docs-related commits will follow, but this needs to be merged in order to continue with other development. * Docs: Overhaul docs generator (beginning) * docs: Rename comments file * docs: Move comments gitignore * docs: Initial request documentation * docs: Improvements to comment processing * docs: More improvements * docs: Add enum functionality for protocol.json * WebSocketServer: Document enums * RequestHandler: Document RequestStatus enum * Base: Move ObsWebSocketRequestBatchExecutionType to its own file Moves it to its own file, renaming it to `RequestBatchExecutionType`. Changes the RPC to use integer values for selecting execution type instead of strings. * docs: Update introduction header Removes the enum section, and documents RequestBatchExecutionType. * WebSocketCloseCode: Shuffle a bit * Base: Use `field` instead of `key` or `parameter` in most places * RequestStatus: Mild shuffle It was really bothering me that OutputPaused and OutputNotPaused had to be separated, so we're breaking it while we're breaking other stuff. * docs: Delete old files They may be added back in some form, but for now I'm getting them out of the way. * docs: Add enum identifier value Forgot to add this before, oops * docs: Document more enums * docs: Add basic protocol.md generator * docs: More work on MD generator * docs: MD generator should be finished now * docs: More fixes * docs: More fixes * docs: More tweaks + add readme * docs: Update readme and add inputs docs * docs: More documentation
2021-12-11 05:38:18 +00:00
/**
* The scene collection list has changed.
*
* @dataField sceneCollections | Array<String> | Updated list of scene collections
*
* @eventType SceneCollectionListChanged
* @eventSubscription Config
* @complexity 1
* @rpcVersion -1
* @initialVersion 5.0.0
* @category config
* @api events
*/
2021-05-14 02:11:19 +00:00
void EventHandler::HandleSceneCollectionListChanged()
{
json eventData;
eventData["sceneCollections"] = Utils::Obs::ArrayHelper::GetSceneCollectionList();
BroadcastEvent(EventSubscription::Config, "SceneCollectionListChanged", eventData);
2021-05-14 02:11:19 +00:00
}
docs: Overhaul documentation (#863) More docs-related commits will follow, but this needs to be merged in order to continue with other development. * Docs: Overhaul docs generator (beginning) * docs: Rename comments file * docs: Move comments gitignore * docs: Initial request documentation * docs: Improvements to comment processing * docs: More improvements * docs: Add enum functionality for protocol.json * WebSocketServer: Document enums * RequestHandler: Document RequestStatus enum * Base: Move ObsWebSocketRequestBatchExecutionType to its own file Moves it to its own file, renaming it to `RequestBatchExecutionType`. Changes the RPC to use integer values for selecting execution type instead of strings. * docs: Update introduction header Removes the enum section, and documents RequestBatchExecutionType. * WebSocketCloseCode: Shuffle a bit * Base: Use `field` instead of `key` or `parameter` in most places * RequestStatus: Mild shuffle It was really bothering me that OutputPaused and OutputNotPaused had to be separated, so we're breaking it while we're breaking other stuff. * docs: Delete old files They may be added back in some form, but for now I'm getting them out of the way. * docs: Add enum identifier value Forgot to add this before, oops * docs: Document more enums * docs: Add basic protocol.md generator * docs: More work on MD generator * docs: MD generator should be finished now * docs: More fixes * docs: More fixes * docs: More tweaks + add readme * docs: Update readme and add inputs docs * docs: More documentation
2021-12-11 05:38:18 +00:00
/**
* The current profile has begun changing.
*
* @dataField profileName | String | Name of the current profile
*
* @eventType CurrentProfileChanging
* @eventSubscription Config
* @complexity 1
* @rpcVersion -1
* @initialVersion 5.0.0
* @category config
* @api events
*/
void EventHandler::HandleCurrentProfileChanging()
{
json eventData;
eventData["profileName"] = Utils::Obs::StringHelper::GetCurrentProfile();
BroadcastEvent(EventSubscription::Config, "CurrentProfileChanging", eventData);
}
docs: Overhaul documentation (#863) More docs-related commits will follow, but this needs to be merged in order to continue with other development. * Docs: Overhaul docs generator (beginning) * docs: Rename comments file * docs: Move comments gitignore * docs: Initial request documentation * docs: Improvements to comment processing * docs: More improvements * docs: Add enum functionality for protocol.json * WebSocketServer: Document enums * RequestHandler: Document RequestStatus enum * Base: Move ObsWebSocketRequestBatchExecutionType to its own file Moves it to its own file, renaming it to `RequestBatchExecutionType`. Changes the RPC to use integer values for selecting execution type instead of strings. * docs: Update introduction header Removes the enum section, and documents RequestBatchExecutionType. * WebSocketCloseCode: Shuffle a bit * Base: Use `field` instead of `key` or `parameter` in most places * RequestStatus: Mild shuffle It was really bothering me that OutputPaused and OutputNotPaused had to be separated, so we're breaking it while we're breaking other stuff. * docs: Delete old files They may be added back in some form, but for now I'm getting them out of the way. * docs: Add enum identifier value Forgot to add this before, oops * docs: Document more enums * docs: Add basic protocol.md generator * docs: More work on MD generator * docs: MD generator should be finished now * docs: More fixes * docs: More fixes * docs: More tweaks + add readme * docs: Update readme and add inputs docs * docs: More documentation
2021-12-11 05:38:18 +00:00
/**
* The current profile has changed.
*
* @dataField profileName | String | Name of the new profile
*
* @eventType CurrentProfileChanged
* @eventSubscription Config
* @complexity 1
* @rpcVersion -1
* @initialVersion 5.0.0
* @category config
* @api events
*/
2021-05-14 02:11:19 +00:00
void EventHandler::HandleCurrentProfileChanged()
{
json eventData;
eventData["profileName"] = Utils::Obs::StringHelper::GetCurrentProfile();
BroadcastEvent(EventSubscription::Config, "CurrentProfileChanged", eventData);
2021-05-14 02:11:19 +00:00
}
docs: Overhaul documentation (#863) More docs-related commits will follow, but this needs to be merged in order to continue with other development. * Docs: Overhaul docs generator (beginning) * docs: Rename comments file * docs: Move comments gitignore * docs: Initial request documentation * docs: Improvements to comment processing * docs: More improvements * docs: Add enum functionality for protocol.json * WebSocketServer: Document enums * RequestHandler: Document RequestStatus enum * Base: Move ObsWebSocketRequestBatchExecutionType to its own file Moves it to its own file, renaming it to `RequestBatchExecutionType`. Changes the RPC to use integer values for selecting execution type instead of strings. * docs: Update introduction header Removes the enum section, and documents RequestBatchExecutionType. * WebSocketCloseCode: Shuffle a bit * Base: Use `field` instead of `key` or `parameter` in most places * RequestStatus: Mild shuffle It was really bothering me that OutputPaused and OutputNotPaused had to be separated, so we're breaking it while we're breaking other stuff. * docs: Delete old files They may be added back in some form, but for now I'm getting them out of the way. * docs: Add enum identifier value Forgot to add this before, oops * docs: Document more enums * docs: Add basic protocol.md generator * docs: More work on MD generator * docs: MD generator should be finished now * docs: More fixes * docs: More fixes * docs: More tweaks + add readme * docs: Update readme and add inputs docs * docs: More documentation
2021-12-11 05:38:18 +00:00
/**
* The profile list has changed.
*
* @dataField profiles | Array<String> | Updated list of profiles
*
* @eventType ProfileListChanged
* @eventSubscription Config
* @complexity 1
* @rpcVersion -1
* @initialVersion 5.0.0
* @category config
* @api events
*/
2021-05-14 02:11:19 +00:00
void EventHandler::HandleProfileListChanged()
{
json eventData;
eventData["profiles"] = Utils::Obs::ArrayHelper::GetProfileList();
BroadcastEvent(EventSubscription::Config, "ProfileListChanged", eventData);
2021-05-14 02:11:19 +00:00
}