mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-06-08 08:52:27 +02:00
Close publishers/subscribers if proxy session is closed.
This commit is contained in:
parent
6841d1495f
commit
4c77ae04ef
|
@ -934,8 +934,11 @@ func (s *ProxyServer) DeleteSession(id uint64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ProxyServer) deleteSessionLocked(id uint64) {
|
func (s *ProxyServer) deleteSessionLocked(id uint64) {
|
||||||
delete(s.sessions, id)
|
if session, found := s.sessions[id]; found {
|
||||||
statsSessionsCurrent.Dec()
|
delete(s.sessions, id)
|
||||||
|
session.Close()
|
||||||
|
statsSessionsCurrent.Dec()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ProxyServer) StoreClient(id string, client signaling.McuClient) {
|
func (s *ProxyServer) StoreClient(id string, client signaling.McuClient) {
|
||||||
|
|
|
@ -95,6 +95,11 @@ func (s *ProxySession) MarkUsed() {
|
||||||
atomic.StoreInt64(&s.lastUsed, now.UnixNano())
|
atomic.StoreInt64(&s.lastUsed, now.UnixNano())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ProxySession) Close() {
|
||||||
|
s.clearPublishers()
|
||||||
|
s.clearSubscribers()
|
||||||
|
}
|
||||||
|
|
||||||
func (s *ProxySession) SetClient(client *ProxyClient) *ProxyClient {
|
func (s *ProxySession) SetClient(client *ProxyClient) *ProxyClient {
|
||||||
s.clientLock.Lock()
|
s.clientLock.Lock()
|
||||||
prev := s.client
|
prev := s.client
|
||||||
|
@ -250,7 +255,10 @@ func (s *ProxySession) clearPublishers() {
|
||||||
defer s.publishersLock.Unlock()
|
defer s.publishersLock.Unlock()
|
||||||
|
|
||||||
go func(publishers map[string]signaling.McuPublisher) {
|
go func(publishers map[string]signaling.McuPublisher) {
|
||||||
for _, publisher := range publishers {
|
for id, publisher := range publishers {
|
||||||
|
if s.proxy.DeleteClient(id, publisher) {
|
||||||
|
statsPublishersCurrent.WithLabelValues(publisher.StreamType()).Dec()
|
||||||
|
}
|
||||||
publisher.Close(context.Background())
|
publisher.Close(context.Background())
|
||||||
}
|
}
|
||||||
}(s.publishers)
|
}(s.publishers)
|
||||||
|
@ -263,7 +271,10 @@ func (s *ProxySession) clearSubscribers() {
|
||||||
defer s.publishersLock.Unlock()
|
defer s.publishersLock.Unlock()
|
||||||
|
|
||||||
go func(subscribers map[string]signaling.McuSubscriber) {
|
go func(subscribers map[string]signaling.McuSubscriber) {
|
||||||
for _, subscriber := range subscribers {
|
for id, subscriber := range subscribers {
|
||||||
|
if s.proxy.DeleteClient(id, subscriber) {
|
||||||
|
statsSubscribersCurrent.WithLabelValues(subscriber.StreamType()).Dec()
|
||||||
|
}
|
||||||
subscriber.Close(context.Background())
|
subscriber.Close(context.Background())
|
||||||
}
|
}
|
||||||
}(s.subscribers)
|
}(s.subscribers)
|
||||||
|
|
Loading…
Reference in a new issue