Skip to content

Commit

Permalink
Version 3.1.0
Browse files Browse the repository at this point in the history
- License Change.
- Added UDP Peer Documentation.
- Depend upon CoreOSC 1.1.0.
- Fixed TCP stream framing bug.

Signed-off-by: Sam Smallman <[email protected]>
  • Loading branch information
sammysmallman committed Feb 5, 2022
1 parent 7bce35d commit f598277
Show file tree
Hide file tree
Showing 30 changed files with 1,942 additions and 597 deletions.
92 changes: 0 additions & 92 deletions .swiftpm/xcode/xcshareddata/xcschemes/OSCKit.xcscheme

This file was deleted.

695 changes: 674 additions & 21 deletions LICENSE

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
},
{
"package": "CoreOSC",
"repositoryURL": "https://github.com/sammysmallman/CoreOSC",
"repositoryURL": "https://github.com/sammysmallman/CoreOSC.git",
"state": {
"branch": null,
"revision": "9a8524b3822002e3536528b77008e01a59c2b224",
"version": "1.0.0"
"revision": "c8f1080e31dae7bcfbd1660018f2ed8b11228e1a",
"version": "1.1.0"
}
},
{
Expand Down
11 changes: 9 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/robbiehanson/CocoaAsyncSocket", from: "7.6.4"),
.package(name: "NetUtils" ,url: "https://github.com/svdo/swift-netutils", from: "4.1.0"),
.package(url: "https://github.com/sammysmallman/CoreOSC", from: "1.0.0")
.package(url: "https://github.com/sammysmallman/CoreOSC.git", from: "1.1.0")
],
targets: [
.target(
name: "OSCKit",
dependencies: ["CocoaAsyncSocket", "NetUtils", "CoreOSC"]),
dependencies: [
"CocoaAsyncSocket",
"NetUtils",
"CoreOSC"
],
resources: [
.process("LICENSE.md")
]),
.testTarget(
name: "OSCKitTests",
dependencies: ["OSCKit"])
Expand Down
98 changes: 84 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ Use the OSCKit package to create client or server objects. In its simplest form

OSCKit implements all required argument types as specified in [OSC 1.1](http://opensoundcontrol.org/files/2009-NIME-OSC-1.1.pdf).

An example project can be found in [OSCKitDemo](https://github.com/sammysmallman/OSCKitDemo).

## License
OSCKit is licensed under the GNU Affero General Public License, version 3. If you require a commercial license for an application that you would not like to trigger AGPLv3 obligations (e.g. open sourcing your application), please get in touch. The probability of obtaining a commerical license for free is high.

## Features

- UDP and TCP Transport options
- UDP Servers can join multicast groups
- UDP Clients can broadcast packets
- UDP Peer (A shared socket for sending and receiving OSC packets on)
- TCP Server with client management
- TCP Stream Framing
- OSC Bundles
Expand All @@ -33,13 +39,13 @@ Add the package dependency to your Package.swift and depend on "OSCKit" in the n

``` swift
dependencies: [
.package(url: "https://github.com/SammySmallman/OSCKit", .upToNextMajor(from: "3.0.1"))
.package(url: "https://github.com/SammySmallman/OSCKit", .upToNextMajor(from: "3.1.0"))
]
```

#### App Sandbox Network Settings
- Enable Incoming Connections *(Required for OSCTcpClient, OSCTcpServer & OSCUdpServer)*
- Enable Outgoing Connections *(Required for OSCTcpClient, OSCTcpServer & OSCUdpClient)*
- Enable Incoming Connections *(Required for OSCTcpClient, OSCTcpServer, OSCUdpPeer & OSCUdpServer)*
- Enable Outgoing Connections *(Required for OSCTcpClient, OSCTcpServer, OSCUdpPeer & OSCUdpClient)*

## Quick Start

Expand Down Expand Up @@ -69,15 +75,15 @@ Conform to the clients delegate protocol OSCTcpClientDelegate:
func client(_ client: OSCTcpClient,
didConnectTo host: String,
port: UInt16) {
print("client did connect to \(host):\(port)")
print("Client did connect to \(host):\(port)")
}

func client(_ client: OSCTcpClient,
didDisconnectWith error: Error?) {
if let error = error {
print("client did disconnect with error: \(error.localizedDescription)")
print("Client did disconnect with error: \(error.localizedDescription)")
} else {
print("client did disconnect")
print("Client did disconnect")
}
}

Expand Down Expand Up @@ -169,9 +175,9 @@ func server(_ server: OSCTcpServer,
func server(_ server: OSCTcpServer,
socketDidCloseWithError error: Error?) {
if let error = error {
print("server did stop listening with error: \(error.localizedDescription)")
print("Server did stop listening with error: \(error.localizedDescription)")
} else {
print("server did stop listening")
print("Server did stop listening")
}
}

Expand Down Expand Up @@ -219,15 +225,15 @@ func client(_ client: OSCUdpClient,
didSendPacket packet: OSCPacket,
fromHost host: String?,
port: UInt16?) {
print("client sent packet to \(client.host):\(client.port)")
print("Client sent packet to \(client.host):\(client.port)")
}

func client(_ client: OSCUdpClient,
didNotSendPacket packet: OSCPacket,
fromHost host: String?,
port: UInt16?,
error: Error?) {
print("client did not send packet to \(client.host):\(client.port)")
print("Client did not send packet to \(client.host):\(client.port)")
}

func client(_ client: OSCUdpClient,
Expand Down Expand Up @@ -282,15 +288,15 @@ func server(_ server: OSCUdpServer,
didReceivePacket packet: OSCPacket,
fromHost host: String,
port: UInt16) {
print("server did receive packet from \(host):\(port)")
print("Server did receive packet from \(host):\(port)")
}

func server(_ server: OSCUdpServer,
socketDidCloseWithError error: Error?) {
if let error = error {
print("server did stop listening with error: \(error.localizedDescription)")
print("Server did stop listening with error: \(error.localizedDescription)")
} else {
print("server did stop listening")
print("Server did stop listening")
}
}

Expand All @@ -313,6 +319,70 @@ do {
```
</details>

<details closed>
<summary>UDP Peer</summary>
<h4>Step 1</h4>

Import OSCKit into your project
```swift
import OSCKit
```

<h4>Step 2</h4>

Create a peer
```swift
let peer = OSCUdpPeer(host: "10.101.130.101",
port: 24601,
hostPort: 3001)
```

<h4>Step 3</h4>

Conform to the peers delegate protocol OSCUdpPeerDelegate:
```swift
func peer(_ peer: OSCUdpPeer, didReceivePacket packet: OSCPacket, fromHost host: String, port: UInt16) {
print("Peer did receive packet from \(host):\(port)")
}

func peer(_ peer: OSCUdpPeer, didReadData data: Data, with error: Error) {
print("Peer did read data with error: \(error.localizedDescription)")
}

func peer(_ peer: OSCUdpPeer, didSendPacket packet: OSCPacket, fromHost host: String?, port: UInt16?) {
print("Peer sent packet to \(peer.host):\(peer.hostPort) from \(host):\(port)")
}

func peer(_ peer: OSCUdpPeer, didNotSendPacket packet: OSCPacket, fromHost host: String?, port: UInt16?, error: Error?) {
print("Peer did not send packet to \(peer.host):\(peer.hostPort) from \(host):\(port)")
}

func peer(_ peer: OSCUdpPeer, socketDidCloseWithError error: Error?) {
print("Peer Error: \(error.localizedDescription)")
}
```

<h4>Step 4</h4>

Create an OSCPacket e.g. An OSC message:
```swift
do {
let message = try OSCMessage(with: "/osc/kit", arguments: [1,
3.142,
"hello world!"])
} catch {
print("Unable to create OSCMessage: \(error.localizedDescription)")
}
```

<h4>Step 5</h4>

Send the packet
```swift
peer.send(message)
```
</details>

## CoreOSC

OSCKit is supported by the infrastructural code provided by [CoreOSC](https://github.com/sammysmallman/CoreOSC). For more detailed information pertaining to the OSC objects that OSCKit uses, such as Address Patterns, Messages and Bundles, please direct all queries to [CoreOSC](https://github.com/sammysmallman/CoreOSC).
Expand All @@ -321,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
29 changes: 13 additions & 16 deletions Sources/OSCKit/Extensions/Interface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,22 @@
// OSCKit
//
// Created by Sam Smallman on 29/10/2017.
// Copyright © 2020 Sam Smallman. https://github.com/SammySmallman
// Copyright © 2022 Sam Smallman. https://github.com/SammySmallman
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// This file is part of OSCKit
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// OSCKit is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// OSCKit is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

import Foundation
Expand Down
29 changes: 13 additions & 16 deletions Sources/OSCKit/Extensions/Numeric.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,22 @@
// OSCKit
//
// Created by Sam Smallman on 13/07/2021.
// Copyright © 2020 Sam Smallman. https://github.com/SammySmallman
// Copyright © 2022 Sam Smallman. https://github.com/SammySmallman
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// This file is part of OSCKit
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// OSCKit is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// OSCKit is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

import Foundation
Expand Down
Loading

0 comments on commit f598277

Please sign in to comment.