mirror of
https://git.sr.ht/~ashkeel/strimertul
synced 2024-09-18 01:50:50 +00:00
fix: don't resubscribe if reconnection has same ID
This commit is contained in:
parent
4c0708138a
commit
b9181c2d99
2 changed files with 17 additions and 9 deletions
|
@ -118,6 +118,11 @@ func (c *Client) processEvent(message EventSubWebsocketMessage) {
|
|||
}
|
||||
|
||||
func (c *Client) addSubscriptionsForSession(session string) error {
|
||||
if c.savedSubscriptions[session] {
|
||||
// Already subscribed
|
||||
return nil
|
||||
}
|
||||
|
||||
client, err := c.GetUserClient()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed getting API client for user: %w", err)
|
||||
|
@ -152,6 +157,7 @@ func (c *Client) addSubscriptionsForSession(session string) error {
|
|||
return fmt.Errorf("error subscribing to %s: %w", topic, err)
|
||||
}
|
||||
}
|
||||
c.savedSubscriptions[session] = true
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ type Client struct {
|
|||
|
||||
restart chan bool
|
||||
streamOnline *containers.RWSync[bool]
|
||||
savedSubscriptions map[string]bool
|
||||
}
|
||||
|
||||
func NewClient(db *database.LocalDBClient, server *http.Server, logger *zap.Logger) (*Client, error) {
|
||||
|
@ -52,6 +53,7 @@ func NewClient(db *database.LocalDBClient, server *http.Server, logger *zap.Logg
|
|||
restart: make(chan bool, 128),
|
||||
streamOnline: containers.NewRWSync(false),
|
||||
eventCache: eventCache,
|
||||
savedSubscriptions: make(map[string]bool),
|
||||
}
|
||||
|
||||
// Listen for Config changes
|
||||
|
|
Loading…
Reference in a new issue