From fc0a7ba29de645c9dd796f62f89175ef86dcd38d Mon Sep 17 00:00:00 2001 From: Nonoo Date: Wed, 21 Oct 2020 15:42:59 +0200 Subject: [PATCH] Move disconnect send to the common stream close function --- controlstream.go | 40 +++++++++++++++------------------------- main.go | 6 +++--- streamcommon.go | 1 + 3 files changed, 19 insertions(+), 28 deletions(-) diff --git a/controlstream.go b/controlstream.go index 1a0d92d..3e1a8ad 100644 --- a/controlstream.go +++ b/controlstream.go @@ -92,31 +92,21 @@ func (s *controlStream) sendPktReauth(firstReauthSend bool) { s.authInnerSendSeq++ } -func (s *controlStream) sendDisconnect() { - if s.common.conn == nil { - return - } - // s.common.send([]byte{0x40, 0x00, 0x00, 0x00, 0x00, 0x00, byte(s.authSendSeq), byte(s.authSendSeq >> 8), - // byte(s.common.localSID >> 24), byte(s.common.localSID >> 16), byte(s.common.localSID >> 8), byte(s.common.localSID), - // byte(s.common.remoteSID >> 24), byte(s.common.remoteSID >> 16), byte(s.common.remoteSID >> 8), byte(s.common.remoteSID), - // 0x00, 0x00, 0x00, 0x30, 0x01, 0x01, 0x00, byte(s.authInnerSendSeq), - // byte(s.authInnerSendSeq >> 8), 0x00, s.authID[0], s.authID[1], s.authID[2], s.authID[3], s.authID[4], s.authID[5], - // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}) - s.common.sendDisconnect() -} - -func (s *controlStream) sendPkt0() { - p := []byte{0x10, 0x00, 0x00, 0x00, 0x00, 0x00, byte(s.authSendSeq), byte(s.authSendSeq >> 8), - byte(s.common.localSID >> 24), byte(s.common.localSID >> 16), byte(s.common.localSID >> 8), byte(s.common.localSID), - byte(s.common.remoteSID >> 24), byte(s.common.remoteSID >> 16), byte(s.common.remoteSID >> 8), byte(s.common.remoteSID)} - s.common.send(p) - s.common.send(p) - - s.authSendSeq++ -} +// func (s *controlStream) sendDisconnect() { TODO +// if s.common.conn == nil { +// return +// } +// s.common.send([]byte{0x40, 0x00, 0x00, 0x00, 0x00, 0x00, byte(s.authSendSeq), byte(s.authSendSeq >> 8), +// byte(s.common.localSID >> 24), byte(s.common.localSID >> 16), byte(s.common.localSID >> 8), byte(s.common.localSID), +// byte(s.common.remoteSID >> 24), byte(s.common.remoteSID >> 16), byte(s.common.remoteSID >> 8), byte(s.common.remoteSID), +// 0x00, 0x00, 0x00, 0x30, 0x01, 0x01, 0x00, byte(s.authInnerSendSeq), +// byte(s.authInnerSendSeq >> 8), 0x00, s.authID[0], s.authID[1], s.authID[2], s.authID[3], s.authID[4], s.authID[5], +// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}) +// s.common.sendDisconnect() +// } func (s *controlStream) sendRequestSerialAndAudio() { log.Print("requesting serial and audio stream") diff --git a/main.go b/main.go index 884d5bd..323064f 100644 --- a/main.go +++ b/main.go @@ -19,9 +19,9 @@ func exit(err error) { log.Error(err.Error()) } - streams.audio.sendDisconnect() - streams.serial.sendDisconnect() - streams.control.sendDisconnect() + streams.audio.common.close() + streams.serial.common.close() + streams.control.common.close() serialPort.deinit() audio.deinit() diff --git a/streamcommon.go b/streamcommon.go index a4dcb62..f20c6b4 100644 --- a/streamcommon.go +++ b/streamcommon.go @@ -108,6 +108,7 @@ func (s *streamCommon) open(name string, portNumber int) { } func (s *streamCommon) close() { + s.sendDisconnect() s.conn.Close() // Depleting the read channel.