28 lines
657 B
Go
28 lines
657 B
Go
package main
|
|
|
|
import "sync"
|
|
|
|
// Global state management
|
|
var (
|
|
interactionStates = make(map[string]*InteractionState)
|
|
interactionStatesMutex = sync.RWMutex{}
|
|
)
|
|
|
|
func getInteractionState(token string) *InteractionState {
|
|
interactionStatesMutex.RLock()
|
|
defer interactionStatesMutex.RUnlock()
|
|
return interactionStates[token]
|
|
}
|
|
|
|
func setInteractionState(token string, state *InteractionState) {
|
|
interactionStatesMutex.Lock()
|
|
defer interactionStatesMutex.Unlock()
|
|
interactionStates[token] = state
|
|
}
|
|
|
|
func deleteInteractionState(token string) {
|
|
interactionStatesMutex.Lock()
|
|
defer interactionStatesMutex.Unlock()
|
|
delete(interactionStates, token)
|
|
}
|