Skip to content
This repository was archived by the owner on May 31, 2021. It is now read-only.

Commit

Permalink
Fix some voice errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Azoy committed Jul 10, 2017
1 parent 5fcd6fc commit 1869b60
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions Sources/Sword/Voice/VoiceConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,6 @@ public class VoiceConnection: Gateway, Eventable {
*/
func handleDisconnect(for code: Int) {
guard CloseOP(rawValue: code) != nil else {
print("[Sword] Voice connection closed with unrecognized response\nCode: \(code)")

return
}
}
Expand Down Expand Up @@ -398,8 +396,8 @@ public class VoiceConnection: Gateway, Eventable {

process.standardOutput = self.writer

process.terminationHandler = { [unowned self] _ in
self.finish()
process.terminationHandler = { [weak self] _ in
self?.finish()
}

process.launch()
Expand Down Expand Up @@ -458,7 +456,7 @@ public class VoiceConnection: Gateway, Eventable {
guard let audioData = try self?.decryptPacket(with: Data(bytes: data)) else { return }
self?.emit(.audioData, with: audioData)
}catch {
guard let isConnected = self?.isConnected, !isConnected else { return }
guard let isConnected = self?.isConnected, isConnected else { return }

print("[Sword] Unable to read voice data from guild: \(self?.guildId as Any).")
}
Expand Down Expand Up @@ -565,17 +563,17 @@ public class VoiceConnection: Gateway, Eventable {
self.emit(.connectionClose)
}

self.heartbeat = nil
self.isConnected = false
self.encoder = nil

#if !os(Linux)
self.session?.disconnect()
#else
try? self.session?.close()
#endif

try? self.udpClient?.close()

self.heartbeat = nil
self.isConnected = false
self.encoder = nil
}

}
Expand Down

0 comments on commit 1869b60

Please sign in to comment.