Skip to content

Commit

Permalink
Merge pull request #3 from sammysmallman/Spelling-and-Grammar
Browse files Browse the repository at this point in the history
Spelling and Grammar
  • Loading branch information
sammysmallman authored Feb 15, 2022
2 parents 4b3acf3 + 385b0ef commit 2385576
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 46 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ OSCKit is supported by the infrastructural code provided by [CoreOSC](https://gi

**Sammy Smallman** - *Initial Work* - [SammySmallman](https://github.com/sammysmallman)

See also the list of [contributors](https://github.com/SammyTheHand/OSCKit/graphs/contributors) who participated in this project.
See also the list of [contributors](https://github.com/sammysmallman/OSCKit/graphs/contributors) who participated in this project.

## Acknowledgments

Expand Down
2 changes: 1 addition & 1 deletion Sources/OSCKit/Extensions/Interface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extension Interface {
}

open var displayText: String {
return "\(self.displayName) (\(self.name)) - \(self.address ?? "")"
"\(self.displayName) (\(self.name)) - \(self.address ?? "")"
}
#endif
}
10 changes: 4 additions & 6 deletions Sources/OSCKit/Extensions/UInt32.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ extension UInt32 {

internal func byteArray() -> [UInt8] {
var bigEndian = self.bigEndian
let count = MemoryLayout<UInt32>.size
let bytePtr = withUnsafePointer(to: &bigEndian) {
$0.withMemoryRebound(to: UInt8.self, capacity: count) {
UnsafeBufferPointer(start: $0, count: count)
return Array(withUnsafePointer(to: &bigEndian) {
$0.withMemoryRebound(to: UInt8.self, capacity: MemoryLayout<UInt32>.size) {
UnsafeBufferPointer(start: $0, count: MemoryLayout<UInt32>.size)
}
}
return Array(bytePtr)
})
}

}
4 changes: 2 additions & 2 deletions Sources/OSCKit/OSCKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public enum OSCKit {
static let coreOscVersion: String = "/sdk/coreosc/version"
/// An address pattern for retrieving the sdk's license.
static let coreOscLicense: String = "/sdk/coreosc/license"
/// Returns a `OSCMessage` response corresponding to the given packet.

/// Returns an `OSCMessage` response corresponding to the given packet.
static func message(for packet: OSCPacket) -> OSCMessage? {
guard let message = packet as? OSCMessage else { return nil }
switch message.addressPattern.fullPath {
Expand Down
4 changes: 2 additions & 2 deletions Sources/OSCKit/OSCTcp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal struct OSCTcp {
/// - packet: The `OSCPacket` to be sent.
/// - streamFraming: The method the packet will be encoded with.
/// - socket: A TCP socket.
/// - timeout: The timeout for the send opeartion. If the timeout value is negative,
/// - timeout: The timeout for the send operartion. If the timeout value is negative,
/// the send operation will not use a timeout.
/// - tag: A convenienve tag, reported back with the
/// GCDAsyncSocketDelegate method `socket(_:didWriteDataWithTag:)`.
Expand All @@ -71,7 +71,7 @@ internal struct OSCTcp {
/// - data: Data from an `OSCPacket`.
/// - streamFraming: The method the packet will be encoded with.
/// - socket: A TCP socket.
/// - timeout: The timeout for the send opeartion. If the timeout value is negative,
/// - timeout: The timeout for the send operartion. If the timeout value is negative,
/// the send operation will not use a timeout.
/// - tag: A convenienve tag, reported back with the
/// GCDAsyncSocketDelegate method `socket(_:didWriteDataWithTag:)`.
Expand Down
10 changes: 7 additions & 3 deletions Sources/OSCKit/OSCTcpClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ public class OSCTcpClient: NSObject {
/// The clients local port.
public var localPort: UInt16? { socket.localPort }

/// The timeout for the connect opeartion.
/// The timeout for the connect operartion.
/// If the timeout value is negative, the connect operation will not use a timeout.
public var connectingTimeout: TimeInterval = 1

/// The timeout for the send opeartion.
/// The timeout for the send operartion.
/// If the timeout value is negative, the send operation will not use a timeout.
public var timeout: TimeInterval = -1

Expand Down Expand Up @@ -140,7 +140,11 @@ public class OSCTcpClient: NSObject {
public init(configuration: OSCTcpClientConfiguration,
delegate: OSCTcpClientDelegate? = nil,
queue: DispatchQueue = .main) {
interface = configuration.interface
if configuration.interface?.isEmpty == false {
interface = configuration.interface
} else {
interface = nil
}
host = configuration.host
port = configuration.port
streamFraming = configuration.streamFraming
Expand Down
11 changes: 5 additions & 6 deletions Sources/OSCKit/OSCTcpServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class OSCTcpServer: NSObject {
sockets.compactMap { (host: $0.value.host, port: $0.value.port) }
}

/// The timeout for the read and write opeartions.
/// The timeout for the read and write operartions.
/// If the timeout value is negative, the send operation will not use a timeout.
public var timeout: TimeInterval = -1

Expand Down Expand Up @@ -127,11 +127,10 @@ public class OSCTcpServer: NSObject {
public init(configuration: OSCTcpServerConfiguration,
delegate: OSCTcpServerDelegate? = nil,
queue: DispatchQueue = .main) {
if let configInterface = configuration.interface,
configInterface.isEmpty == false {
self.interface = configInterface
if configuration.interface?.isEmpty == false {
interface = configuration.interface
} else {
self.interface = nil
interface = nil
}
port = configuration.port
streamFraming = configuration.streamFraming
Expand Down Expand Up @@ -169,7 +168,7 @@ public class OSCTcpServer: NSObject {

// MARK: Listening

/// Start the server listening
/// Start the server listening.
/// - Throws: An error relating to the setting up of the socket.
///
/// The server will accept connections on the servers port. If an interface
Expand Down
11 changes: 5 additions & 6 deletions Sources/OSCKit/OSCUdpClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class OSCUdpClient: NSObject {
/// The clients UDP socket that all OSCPackets are sent from.
private let socket: GCDAsyncUdpSocket = GCDAsyncUdpSocket()

/// The timeout for the send opeartion.
/// The timeout for the send operartion.
/// If the timeout value is negative, the send operation will not use a timeout.
public var timeout: TimeInterval = 3

Expand All @@ -76,14 +76,14 @@ public class OSCUdpClient: NSObject {
/// A dictionary of `OSCPackets` keyed by the sequenced `tag` number.
///
/// This allows for a reference to a sent packet when the
/// GCDAsynUDPSocketDelegate method udpSocket(_:didSendDataWithTag:) is called.
/// GCDAsyncUDPSocketDelegate method udpSocket(_:didSendDataWithTag:) is called.
private var sendingPackets: [Int: OSCSentPacket] = [:]

/// A sequential tag that is increased and associated with each packet sent.
///
/// The tag will wrap around to 0 if the maximum amount has been reached.
/// This allows for a reference to a sent packet when the
/// GCDAsynUDPSocketDelegate method udpSocket(_:didSendDataWithTag:) is called.
/// GCDAsyncUDPSocketDelegate method udpSocket(_:didSendDataWithTag:) is called.
private var tag: Int = 0

/// An OSC UDP Client.
Expand All @@ -94,9 +94,8 @@ public class OSCUdpClient: NSObject {
public init(configuration: OSCUdpClientConfiguration,
delegate: OSCUdpClientDelegate? = nil,
queue: DispatchQueue = .main) {
if let configInterface = configuration.interface,
configInterface.isEmpty == false {
interface = configInterface
if configuration.interface?.isEmpty == false {
interface = configuration.interface
} else {
interface = nil
}
Expand Down
13 changes: 6 additions & 7 deletions Sources/OSCKit/OSCUdpPeer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,21 @@ public class OSCUdpPeer: NSObject {
/// to allow for multiple processes to simultaneously bind to the same port.
public private(set) var reusePort: Bool = false

/// The timeout for the send opeartion.
/// The timeout for the send operartion.
/// If the timeout value is negative, the send operation will not use a timeout.
public var timeout: TimeInterval = 3

/// A dictionary of `OSCPackets` keyed by the sequenced `tag` number.
///
/// This allows for a reference to a sent packet when the
/// GCDAsynUDPSocketDelegate method udpSocket(_:didSendDataWithTag:) is called.
/// GCDAsyncUDPSocketDelegate method udpSocket(_:didSendDataWithTag:) is called.
private var sendingPackets: [Int: OSCSentPacket] = [:]

/// A sequential tag that is increased and associated with each packet sent.
///
/// The tag will wrap around to 0 if the maximum amount has been reached.
/// This allows for a reference to a sent packet when the
/// GCDAsynUDPSocketDelegate method udpSocket(_:didSendDataWithTag:) is called.
/// GCDAsyncUDPSocketDelegate method udpSocket(_:didSendDataWithTag:) is called.
private var tag: Int = 0

/// The dispatch queue that the peer executes all delegate callbacks on.
Expand All @@ -125,9 +125,8 @@ public class OSCUdpPeer: NSObject {
delegate: OSCUdpPeerDelegate? = nil,
queue: DispatchQueue = .main) {
socket = GCDAsyncUdpSocket()
if let configInterface = configuration.interface,
configInterface.isEmpty == false {
self.interface = configInterface
if configuration.interface?.isEmpty == false {
interface = configuration.interface
} else {
interface = nil
}
Expand Down Expand Up @@ -171,7 +170,7 @@ public class OSCUdpPeer: NSObject {

// MARK: Running

/// Start the peer running
/// Start the peer running.
///
/// The peer will bind its socket to a port. If an interface has been set,
/// it will also bind to that so packets are only received through that interface;
Expand Down
14 changes: 7 additions & 7 deletions Sources/OSCKit/OSCUdpPeerConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ import Foundation
/// The interface may be a name (e.g. "en1" or "lo0") or the corresponding IP address (e.g. "192.168.1.15").
/// If the value of this is nil the peer will use the default interface.
public let interface: String?

/// The port the peer should listen for packets on.
public let port: UInt16

/// The destination the peer should send UDP packets to.
/// May be specified as a domain name (e.g. "google.com") or an IP address string (e.g. "192.168.1.16").
/// You may also use the convenience strings of "loopback" or "localhost".
public let host: String

/// The port the peer should listen for packets on.
public let port: UInt16

/// The port of the host the peer should send packets to.
public let hostPort: UInt16

/// A configuration object that defines the behavior of a UDP peer.
/// - Parameters:
/// - interface: An interface name (e.g. "en1" or "lo0"), the corresponding IP address or nil.
Expand All @@ -74,13 +74,13 @@ import Foundation

/// A key that defines the `interface` of an `OSCUdpPeer`.
private static let interfaceKey = "interfaceKey"

/// A key that defines the `host` of an `OSCUdpPeer`.
private static let hostKey = "hostKey"

/// A key that defines the `port` of an `OSCUdpPeer`.
private static let portKey = "portKey"

/// A key that defines the `hostPort` of an `OSCUdpPeer`.
private static let hostPortKey = "hostPortKey"

Expand Down
9 changes: 4 additions & 5 deletions Sources/OSCKit/OSCUdpServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,10 @@ public class OSCUdpServer: NSObject {
delegate: OSCUdpServerDelegate? = nil,
queue: DispatchQueue = .main) {
socket = GCDAsyncUdpSocket()
if let configInterface = configuration.interface,
configInterface.isEmpty == false {
self.interface = configInterface
if configuration.interface?.isEmpty == false {
interface = configuration.interface
} else {
self.interface = nil
interface = nil
}
port = configuration.port
multicastGroups = configuration.multicastGroups
Expand Down Expand Up @@ -156,7 +155,7 @@ public class OSCUdpServer: NSObject {

// MARK: Listening

/// Start the server listening
/// Start the server listening.
/// - Throws: An error relating to the binding of a socket.
/// Although this method does automatically attempt to join the multicast groups after successfully
/// starting to listen, those errors are not handled here.
Expand Down

0 comments on commit 2385576

Please sign in to comment.