mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-07-01 00:41:07 -05:00
Clear message buffers when macro was paused
This commit is contained in:
parent
cf97c1f60b
commit
1be72218a9
|
|
@ -1,5 +1,6 @@
|
|||
#include "macro-condition-websocket.hpp"
|
||||
#include "layout-helpers.hpp"
|
||||
#include "macro-helpers.hpp"
|
||||
|
||||
#include <regex>
|
||||
|
||||
|
|
@ -32,6 +33,14 @@ bool MacroConditionWebsocket::CheckCondition()
|
|||
return false;
|
||||
}
|
||||
|
||||
const bool macroWasPausedSinceLastCheck =
|
||||
MacroWasPausedSince(GetMacro(), _lastCheck);
|
||||
_lastCheck = std::chrono::high_resolution_clock::now();
|
||||
if (macroWasPausedSinceLastCheck) {
|
||||
_messageBuffer->Clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
while (!_messageBuffer->Empty()) {
|
||||
auto message = _messageBuffer->ConsumeMessage();
|
||||
if (!message) {
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ private:
|
|||
std::weak_ptr<Connection> _connection;
|
||||
|
||||
WebsocketMessageBuffer _messageBuffer;
|
||||
std::chrono::high_resolution_clock::time_point _lastCheck{};
|
||||
|
||||
static bool _registered;
|
||||
static const std::string id;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "macro-condition-midi.hpp"
|
||||
#include "layout-helpers.hpp"
|
||||
#include "macro-helpers.hpp"
|
||||
#include "ui-helpers.hpp"
|
||||
|
||||
namespace advss {
|
||||
|
|
@ -17,6 +18,14 @@ bool MacroConditionMidi::CheckCondition()
|
|||
return false;
|
||||
}
|
||||
|
||||
const bool macroWasPausedSinceLastCheck =
|
||||
MacroWasPausedSince(GetMacro(), _lastCheck);
|
||||
_lastCheck = std::chrono::high_resolution_clock::now();
|
||||
if (macroWasPausedSinceLastCheck) {
|
||||
_messageBuffer->Clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
while (!_messageBuffer->Empty()) {
|
||||
auto message = _messageBuffer->ConsumeMessage();
|
||||
if (!message) {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ private:
|
|||
|
||||
MidiDevice _device;
|
||||
MidiMessageBuffer _messageBuffer;
|
||||
std::chrono::high_resolution_clock::time_point _lastCheck{};
|
||||
static bool _registered;
|
||||
static const std::string id;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "twitch-helpers.hpp"
|
||||
|
||||
#include <layout-helpers.hpp>
|
||||
#include <macro-helpers.hpp>
|
||||
#include <log-helper.hpp>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
|
|
@ -363,6 +364,9 @@ bool MacroConditionTwitch::CheckChatMessages(TwitchToken &token)
|
|||
if (!_chatConnection) {
|
||||
_chatConnection = TwitchChatConnection::GetChatConnection(
|
||||
token, _channel);
|
||||
if (!_chatConnection) {
|
||||
return false;
|
||||
}
|
||||
_chatBuffer = _chatConnection->RegisterForMessages();
|
||||
return false;
|
||||
}
|
||||
|
|
@ -435,7 +439,7 @@ void MacroConditionTwitch::SetTempVarValues(const ChannelInfo &info)
|
|||
info.is_branded_content ? "true" : "false");
|
||||
}
|
||||
|
||||
bool advss::MacroConditionTwitch::EventSubscriptionIsSetup(
|
||||
bool MacroConditionTwitch::EventSubscriptionIsSetup(
|
||||
const std::shared_ptr<EventSub> &eventSub)
|
||||
{
|
||||
if (!eventSub) {
|
||||
|
|
@ -449,6 +453,22 @@ bool advss::MacroConditionTwitch::EventSubscriptionIsSetup(
|
|||
return true;
|
||||
}
|
||||
|
||||
void MacroConditionTwitch::HandleMacroPause()
|
||||
{
|
||||
const bool macroWasPausedSinceLastCheck =
|
||||
MacroWasPausedSince(GetMacro(), _lastCheck);
|
||||
_lastCheck = std::chrono::high_resolution_clock::now();
|
||||
|
||||
if (macroWasPausedSinceLastCheck) {
|
||||
if (_eventBuffer) {
|
||||
_eventBuffer->Clear();
|
||||
}
|
||||
if (_chatBuffer) {
|
||||
_chatBuffer->Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool MacroConditionTwitch::CheckCondition()
|
||||
{
|
||||
SetVariableValue("");
|
||||
|
|
@ -458,11 +478,12 @@ bool MacroConditionTwitch::CheckCondition()
|
|||
}
|
||||
|
||||
auto eventSub = token->GetEventSub();
|
||||
|
||||
if (IsUsingEventSubCondition() && !EventSubscriptionIsSetup(eventSub)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HandleMacroPause();
|
||||
|
||||
switch (_condition) {
|
||||
case Condition::STREAM_ONLINE_EVENT:
|
||||
case Condition::STREAM_OFFLINE_EVENT:
|
||||
|
|
|
|||
|
|
@ -119,6 +119,8 @@ private:
|
|||
const char *mainUserIdFieldName = "broadcaster_user_id",
|
||||
obs_data_t *extraConditions = nullptr);
|
||||
|
||||
void HandleMacroPause();
|
||||
|
||||
void SetupTempVars();
|
||||
void SetTempVarValues(const ChannelLiveInfo &);
|
||||
void SetTempVarValues(const ChannelInfo &);
|
||||
|
|
@ -134,6 +136,8 @@ private:
|
|||
ChatMessageBuffer _chatBuffer;
|
||||
std::shared_ptr<TwitchChatConnection> _chatConnection;
|
||||
|
||||
std::chrono::high_resolution_clock::time_point _lastCheck{};
|
||||
|
||||
static bool _registered;
|
||||
static const std::string id;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user