mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-06-29 07:45:33 +00:00
Speed up subscription janitor to 1min
This commit is contained in:
parent
29eb07f58c
commit
377afb7a6b
3 changed files with 13 additions and 8 deletions
|
@ -52,7 +52,7 @@ func commandLineConsole() {
|
|||
if target == "_ALL" {
|
||||
count = server.PublishToAll(msg)
|
||||
} else {
|
||||
count = server.PublishToChat(target, msg)
|
||||
count = server.PublishToChannel(target, msg)
|
||||
}
|
||||
return fmt.Sprintf("Published to %d clients", count), nil
|
||||
})
|
||||
|
|
|
@ -77,6 +77,7 @@ func HandleHello(conn *websocket.Conn, client *ClientInfo, msg ClientMessage) (r
|
|||
}
|
||||
|
||||
SubscribeGlobal(client)
|
||||
SubscribeDefaults(client)
|
||||
|
||||
return ClientMessage{
|
||||
Arguments: client.ClientID.String(),
|
||||
|
|
|
@ -18,18 +18,22 @@ var ChatSubscriptionInfo map[string]*SubscriberList = make(map[string]*Subscribe
|
|||
var ChatSubscriptionLock sync.RWMutex
|
||||
var GlobalSubscriptionInfo SubscriberList
|
||||
|
||||
func SubscribeGlobal(client *ClientInfo) {
|
||||
GlobalSubscriptionInfo.Lock()
|
||||
AddToSliceC(&GlobalSubscriptionInfo.Members, client.MessageChannel)
|
||||
GlobalSubscriptionInfo.Unlock()
|
||||
}
|
||||
|
||||
func SubscribeChannel(client *ClientInfo, channelName string) {
|
||||
ChatSubscriptionLock.RLock()
|
||||
_subscribeWhileRlocked(channelName, client.MessageChannel)
|
||||
ChatSubscriptionLock.RUnlock()
|
||||
}
|
||||
|
||||
func SubscribeDefaults(client *ClientInfo) {
|
||||
|
||||
}
|
||||
|
||||
func SubscribeGlobal(client *ClientInfo) {
|
||||
GlobalSubscriptionInfo.Lock()
|
||||
AddToSliceC(&GlobalSubscriptionInfo.Members, client.MessageChannel)
|
||||
GlobalSubscriptionInfo.Unlock()
|
||||
}
|
||||
|
||||
func PublishToChannel(channel string, msg ClientMessage) (count int) {
|
||||
ChatSubscriptionLock.RLock()
|
||||
list := ChatSubscriptionInfo[channel]
|
||||
|
@ -130,7 +134,7 @@ func unsubscribeAllClients() {
|
|||
ChatSubscriptionLock.Unlock()
|
||||
}
|
||||
|
||||
const ReapingDelay = 20 * time.Minute
|
||||
const ReapingDelay = 1 * time.Minute
|
||||
|
||||
// Checks ChatSubscriptionInfo for entries with no subscribers every ReapingDelay.
|
||||
// Started from SetupServer().
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue