feat: backend service
This commit is contained in:
@@ -273,6 +273,28 @@ func (h *Hub) RevokeDeviceSession(deviceSessionID string) {
|
||||
}
|
||||
}
|
||||
|
||||
// RevokeAllForUser closes every active subscription bound to userID,
|
||||
// regardless of device-session id. Used when backend emits a
|
||||
// SessionInvalidation that targets every session of a user.
|
||||
func (h *Hub) RevokeAllForUser(userID string) {
|
||||
if h == nil {
|
||||
return
|
||||
}
|
||||
|
||||
userID = strings.TrimSpace(userID)
|
||||
if userID == "" {
|
||||
return
|
||||
}
|
||||
|
||||
h.mu.RLock()
|
||||
targets := cloneSubscriptions(h.byUser[userID])
|
||||
h.mu.RUnlock()
|
||||
|
||||
for _, target := range targets {
|
||||
h.unregister(target.id, ErrSubscriptionRevoked)
|
||||
}
|
||||
}
|
||||
|
||||
// Shutdown closes every active subscription because the gateway is shutting
|
||||
// down.
|
||||
func (h *Hub) Shutdown() {
|
||||
|
||||
Reference in New Issue
Block a user