Export CloseSignalConnection (#936)

* Export CloseSignalConnection

There are a few places where that close pattern is repeated.
Export it and use that function in other places directly.

* fix test
This commit is contained in:
Raja Subramanian
2022-08-21 11:33:35 +05:30
committed by GitHub
parent b8bda3f14b
commit 70422c0267
6 changed files with 41 additions and 77 deletions
+5 -4
View File
@@ -10,7 +10,7 @@ import (
"github.com/livekit/livekit-server/pkg/routing"
)
func (p *ParticipantImpl) GetResponseSink() routing.MessageSink {
func (p *ParticipantImpl) getResponseSink() routing.MessageSink {
if !p.resSinkValid.Load() {
return nil
}
@@ -174,7 +174,7 @@ func (p *ParticipantImpl) writeMessage(msg *livekit.SignalResponse) error {
if p.State() == livekit.ParticipantInfo_DISCONNECTED {
return nil
}
sink := p.GetResponseSink()
sink := p.getResponseSink()
if sink == nil {
return nil
}
@@ -188,9 +188,10 @@ func (p *ParticipantImpl) writeMessage(msg *livekit.SignalResponse) error {
}
// closes signal connection to notify client to resume/reconnect
func (p *ParticipantImpl) closeSignalConnection() {
sink := p.GetResponseSink()
func (p *ParticipantImpl) CloseSignalConnection() {
sink := p.getResponseSink()
if sink != nil {
p.params.Logger.Infow("closing signal connection")
sink.Close()
p.SetResponseSink(nil)
}