diff --git a/plugin/manifest.json b/plugin/manifest.json index 06d0545..3635dbf 100644 --- a/plugin/manifest.json +++ b/plugin/manifest.json @@ -37,12 +37,12 @@ "Author": "Meow.tf", "Category": "OBS Replay", "CodePathWin": "replay.exe", - "Description": "Control OBS' Replays using StreamDeck.", + "Description": "Control OBS' Replays using StreamDeck and obs-websocket", "Name": "OBS Replay", "Icon": "images/pluginIcon", "CategoryIcon": "images/pluginIcon", "URL": "https://streamdeck.meow.tf/obsreplay", - "Version": "1.0.0", + "Version": "1.0.1", "SDKVersion": 2, "OS": [ { diff --git a/replay.go b/replay.go index f00b5ef..c31ce12 100644 --- a/replay.go +++ b/replay.go @@ -11,16 +11,16 @@ import ( const ( actionReplayToggle = "tf.meow.obsreplay.replay_toggle" - actionReplaySave = "tf.meow.obsreplay.replay_save" + actionReplaySave = "tf.meow.obsreplay.replay_save" ) var ( contextMutex sync.RWMutex - clientMutex sync.RWMutex - stateMutex sync.RWMutex + clientMutex sync.RWMutex + stateMutex sync.RWMutex - clients = make(map[string]*obsws.Client) - contexts = make(map[string]string) + clients = make(map[string]*obsws.Client) + contexts = make(map[string]string) cachedStates = make(map[string]int) ) @@ -52,6 +52,15 @@ func replaySave(action, context string, payload *fastjson.Value, deviceId string return } + stateMutex.RLock() + state, exists := cachedStates[context] + stateMutex.RUnlock() + + if exists && state == 0 { + sdk.ShowAlert(context) + return + } + req := obsws.NewSaveReplayBufferRequest() if err := req.Send(c); err != nil { @@ -253,4 +262,4 @@ func cleanupSockets() { for _, client := range clients { client.Disconnect() } -} \ No newline at end of file +}