From ff2268306f934238d1db8b1dbec7a6812254d839 Mon Sep 17 00:00:00 2001 From: Emir Aganovic Date: Sun, 9 Aug 2020 21:35:37 +0200 Subject: [PATCH] - Adding missing close sender, receiver connection. This should now exit receiver on finish --- cli/pull.go | 1 + cli/push.go | 2 +- streamer/session.go | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cli/pull.go b/cli/pull.go index 2a7930b..786ecad 100644 --- a/cli/pull.go +++ b/cli/pull.go @@ -37,6 +37,7 @@ func receiveFiles() { if err := r.Dial(); err != nil { log.Fatal(err) } + defer r.Close() wg.Wait() } diff --git a/cli/push.go b/cli/push.go index 63dad7e..048cf64 100644 --- a/cli/push.go +++ b/cli/push.go @@ -101,7 +101,7 @@ func sendFiles(args []string, keepsync bool) error { if err := s.Dial(); err != nil { return errx.Wrapf(err, "Dial failed") } - // defer s.Close() + defer s.Close() //Stream files fmt.Println("") diff --git a/streamer/session.go b/streamer/session.go index 595fff9..1d17f65 100644 --- a/streamer/session.go +++ b/streamer/session.go @@ -40,6 +40,14 @@ func NewSession(SDPReader io.Reader, SDPWriter io.Writer) Session { return sess } +func (s *Session) Close() error { + if s.peerConnection != nil { + return s.peerConnection.Close() + } + + return nil +} + // CreateConnection prepares a WebRTC connection func (s *Session) CreateConnection(onConnectionStateChange func(connectionState webrtc.ICEConnectionState)) error { config := webrtc.Configuration{