Skip to content

Commit

Permalink
Merge branch 'main' of github.com:OperatorFoundation/TransmissionLinux
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr. Brandon Wiley committed Dec 6, 2021
2 parents cf93cb4 + de30066 commit 039ec8b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ let package = Package(
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/OperatorFoundation/Chord", from: "0.0.15"),
.package(url: "https://github.com/OperatorFoundation/Datable", from: "3.1.2"),
.package(url: "https://github.com/OperatorFoundation/Datable", from: "3.1.4"),
.package(name: "Socket", url: "https://github.com/OperatorFoundation/BlueSocket", from: "1.1.0"),
.package(url: "https://github.com/OperatorFoundation/Net", from: "0.0.1"),
.package(url: "https://github.com/OperatorFoundation/Transport", from: "2.3.11"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.4.2")
.package(url: "https://github.com/apple/swift-log.git", from: "1.4.2"),
.package(url: "https://github.com/OperatorFoundation/SwiftHexTools.git", from: "1.2.5")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "TransmissionLinux",
dependencies: [
"Chord", "Socket", "Datable", "Transport", "Net",
"Chord", "Socket", "Datable", "Transport", "Net", "SwiftHexTools",
.product(name: "Logging", package: "swift-log")
]
),
Expand Down
11 changes: 11 additions & 0 deletions Sources/TransmissionLinux/TransmissionConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Datable
import Transport
import Logging
import SwiftQueue
import SwiftHexTools

import Chord
import Socket
Expand Down Expand Up @@ -117,6 +118,7 @@ public class TransmissionConnection: Connection

if size == 0
{
if let log = self.log {log.error("transmission read size was zero")}
readLock.leave()
return nil
}
Expand All @@ -127,11 +129,13 @@ public class TransmissionConnection: Connection
buffer = Data(buffer[size..<buffer.count])

readLock.leave()
print("\nTransmission read returned result: \(result.hex), buffer: \(buffer.hex)\n")
return result
}

guard let data = networkRead(size: size) else
{
if let log = self.log {log.error("transmission read's network read failed")}
readLock.leave()
return nil
}
Expand All @@ -140,6 +144,7 @@ public class TransmissionConnection: Connection

guard size <= buffer.count else
{
if let log = self.log {log.error("transmission read asked for more bytes than available in the buffer")}
readLock.leave()
return nil
}
Expand All @@ -148,6 +153,7 @@ public class TransmissionConnection: Connection
buffer = Data(buffer[size..<buffer.count])

readLock.leave()
print("\nTransmission read returned result: \(result.hex), buffer: \(buffer.hex)\n")
return result
}

Expand Down Expand Up @@ -405,6 +411,11 @@ public class TransmissionConnection: Connection
{
data = Data(data![..<bytesRead])
}
if let realData = data {
print("networkRead size: \(size), bytesRead: \(bytesRead), data: \(realData.hex)")
} else {
print("networkRead size: \(size), bytesRead: \(bytesRead), data: nil")
}
}
catch
{
Expand Down

0 comments on commit 039ec8b

Please sign in to comment.