mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-05-04 06:43:11 +02:00
Keep list of possible dialout sessions.
This commit is contained in:
parent
d1544dcb2c
commit
e1273a3c52
|
@ -674,15 +674,11 @@ func (b *BackendServer) startDialout(roomid string, backend *Backend, request *B
|
|||
return returnDialoutError(http.StatusBadRequest, err)
|
||||
}
|
||||
|
||||
// TODO: Add direct lookup of internal sessions that are not in a room and support dialout.
|
||||
var session *ClientSession
|
||||
for _, s := range b.hub.sessions {
|
||||
if s.GetRoom() == nil && s.ClientType() == HelloClientTypeInternal {
|
||||
clientSession, ok := s.(*ClientSession)
|
||||
if ok && clientSession.GetClient() != nil && clientSession.HasFeature(ClientFeatureStartDialout) {
|
||||
session = clientSession
|
||||
break
|
||||
}
|
||||
for s := range b.hub.dialoutSessions {
|
||||
if s.GetClient() != nil {
|
||||
session = s
|
||||
break
|
||||
}
|
||||
}
|
||||
if session == nil {
|
||||
|
|
14
hub.go
14
hub.go
|
@ -150,6 +150,7 @@ type Hub struct {
|
|||
expiredSessions map[Session]bool
|
||||
anonymousSessions map[*ClientSession]time.Time
|
||||
expectHelloClients map[*Client]time.Time
|
||||
dialoutSessions map[*ClientSession]bool
|
||||
|
||||
backendTimeout time.Duration
|
||||
backend *BackendClient
|
||||
|
@ -338,6 +339,7 @@ func NewHub(config *goconf.ConfigFile, events AsyncEvents, rpcServer *GrpcServer
|
|||
expiredSessions: make(map[Session]bool),
|
||||
anonymousSessions: make(map[*ClientSession]time.Time),
|
||||
expectHelloClients: make(map[*Client]time.Time),
|
||||
dialoutSessions: make(map[*ClientSession]bool),
|
||||
|
||||
backendTimeout: backendTimeout,
|
||||
backend: backend,
|
||||
|
@ -641,6 +643,7 @@ func (h *Hub) removeSession(session Session) (removed bool) {
|
|||
delete(h.expiredSessions, session)
|
||||
if session, ok := session.(*ClientSession); ok {
|
||||
delete(h.anonymousSessions, session)
|
||||
delete(h.dialoutSessions, session)
|
||||
}
|
||||
h.mu.Unlock()
|
||||
return
|
||||
|
@ -802,8 +805,12 @@ func (h *Hub) processRegister(client *Client, message *ClientMessage, backend *B
|
|||
h.sessions[sessionIdData.Sid] = session
|
||||
h.clients[sessionIdData.Sid] = client
|
||||
delete(h.expectHelloClients, client)
|
||||
if userId == "" && auth.Type != HelloClientTypeInternal {
|
||||
if userId == "" && session.ClientType() != HelloClientTypeInternal {
|
||||
h.startWaitAnonymousSessionRoomLocked(session)
|
||||
} else if session.ClientType() == HelloClientTypeInternal && session.HasFeature(ClientFeatureStartDialout) {
|
||||
// TODO: There is a small race condition for sessions that take some time
|
||||
// between connecting and joining a room.
|
||||
h.dialoutSessions[session] = true
|
||||
}
|
||||
h.mu.Unlock()
|
||||
|
||||
|
@ -1250,6 +1257,7 @@ func (h *Hub) processRoom(client *Client, message *ClientMessage) {
|
|||
h.startWaitAnonymousSessionRoom(session)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1389,6 +1397,10 @@ func (h *Hub) processJoinRoom(session *ClientSession, message *ClientMessage, ro
|
|||
h.mu.Lock()
|
||||
// The session now joined a room, don't expire if it is anonymous.
|
||||
delete(h.anonymousSessions, session)
|
||||
if session.ClientType() == HelloClientTypeInternal && session.HasFeature(ClientFeatureStartDialout) {
|
||||
// An internal session in a room can not be used for dialout.
|
||||
delete(h.dialoutSessions, session)
|
||||
}
|
||||
h.mu.Unlock()
|
||||
session.SetRoom(r)
|
||||
if room.Room.Permissions != nil {
|
||||
|
|
Loading…
Reference in a new issue