@@ -10,39 +10,39 @@ import Foundation
1010import Network
1111
1212public class OSCClient {
13-
13+
1414 var connection : NWConnection ?
1515 var queue : DispatchQueue
16-
17- var host : NWEndpoint . Host
16+
17+ public var host : NWEndpoint . Host
1818 public var port : NWEndpoint . Port
19-
19+
2020 public init ? ( host: String , port: Int ) {
21-
21+
2222 // check if string is empty
2323 if host == " " {
24-
24+
2525 NSLog ( " Invalid Hostname: No empty strings allowed. " )
2626 return nil
27-
27+
2828 }
2929 if port > 65535 && port >= 0 {
3030 NSLog ( " Invalid Port: Out of range. " )
3131 return nil
3232 }
33-
33+
3434 self . host = NWEndpoint . Host ( host)
3535 self . port = NWEndpoint . Port ( integerLiteral: UInt16 ( port) )
36-
36+
3737 queue = DispatchQueue ( label: " SwiftOSC Client " )
3838 setupConnection ( )
3939 }
40-
40+
4141 func setupConnection( ) {
42-
42+
4343 // create the connection
4444 connection = NWConnection ( host: host, port: port, using: . udp)
45-
45+
4646 // setup state update handler
4747 connection? . stateUpdateHandler = { [ weak self] ( newState) in
4848 switch newState {
@@ -62,13 +62,13 @@ public class OSCClient {
6262 break
6363 }
6464 }
65-
65+
6666 // start the connection
6767 connection? . start ( queue: queue)
6868 }
69-
69+
7070 public func send( _ element: OSCElement ) {
71-
71+
7272 let data = element. oscData
7373 connection? . send ( content: data, completion: . contentProcessed( { ( error) in
7474 if let error = error {
@@ -80,7 +80,7 @@ public class OSCClient {
8080 // destroy connection and listener
8181 connection? . forceCancel ( )
8282
83-
83+
8484 // setup new listener
8585 setupConnection ( )
8686 }
0 commit comments