Skip to content

Commit

Permalink
changed var host to access level public private(set)
Browse files Browse the repository at this point in the history
changed var host to access level public
  • Loading branch information
soundflix committed Dec 12, 2021
1 parent 5a22299 commit b8665a1
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions Framework/SwiftOSC/Network/OSCClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,39 @@ import Foundation
import Network

public class OSCClient {

var connection: NWConnection?
var queue: DispatchQueue
var host: NWEndpoint.Host
public var port: NWEndpoint.Port

public private(set) var host: NWEndpoint.Host
public private(set) var port: NWEndpoint.Port

public init?(host: String, port: Int) {

// check if string is empty
if host == "" {

NSLog("Invalid Hostname: No empty strings allowed.")
return nil

}
if port > 65535 && port >= 0{
NSLog("Invalid Port: Out of range.")
return nil
}

self.host = NWEndpoint.Host(host)
self.port = NWEndpoint.Port(integerLiteral: UInt16(port))

queue = DispatchQueue(label: "SwiftOSC Client")
setupConnection()
}

func setupConnection(){

// create the connection
connection = NWConnection(host: host, port: port, using: .udp)

// setup state update handler
connection?.stateUpdateHandler = { [weak self] (newState) in
switch newState {
Expand All @@ -62,13 +62,13 @@ public class OSCClient {
break
}
}

// start the connection
connection?.start(queue: queue)
}

public func send(_ element: OSCElement){

let data = element.oscData
connection?.send(content: data, completion: .contentProcessed({ (error) in
if let error = error {
Expand All @@ -80,7 +80,7 @@ public class OSCClient {
// destroy connection and listener
connection?.forceCancel()


// setup new listener
setupConnection()
}
Expand Down

0 comments on commit b8665a1

Please sign in to comment.