mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-05-19 14:06:32 +02:00
Update entry if room session id changes.
This commit is contained in:
parent
bc7dba17c1
commit
92690f4613
|
@ -56,6 +56,14 @@ func (r *BuiltinRoomSessions) SetRoomSession(session Session, roomSessionId stri
|
|||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
if prev, found := r.sessionIdToRoomSession[sid]; found {
|
||||
if prev == roomSessionId {
|
||||
return nil
|
||||
}
|
||||
|
||||
delete(r.roomSessionToSessionid, prev)
|
||||
}
|
||||
|
||||
r.sessionIdToRoomSession[sid] = roomSessionId
|
||||
r.roomSessionToSessionid[roomSessionId] = sid
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ package signaling
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/url"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -145,4 +146,19 @@ func testRoomSessions(t *testing.T, sessions RoomSessions) {
|
|||
} else if sid != s2.PublicId() {
|
||||
t.Errorf("Expected session id %s, got %s", s2.PublicId(), sid)
|
||||
}
|
||||
|
||||
if err := sessions.SetRoomSession(s2, "room-session2"); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if sid, err := sessions.GetSessionId("room-session"); err == nil {
|
||||
t.Errorf("expected error %s, got sid %s", ErrNoSuchRoomSession, sid)
|
||||
} else if !errors.Is(err, ErrNoSuchRoomSession) {
|
||||
t.Errorf("expected %s, got %s", ErrNoSuchRoomSession, err)
|
||||
}
|
||||
|
||||
if sid, err := sessions.GetSessionId("room-session2"); err != nil {
|
||||
t.Errorf("Expected session id %s, got error %s", s2.PublicId(), err)
|
||||
} else if sid != s2.PublicId() {
|
||||
t.Errorf("Expected session id %s, got %s", s2.PublicId(), sid)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue