Skip to content

Commit

Permalink
changed var host to access level public
Browse files Browse the repository at this point in the history
  • Loading branch information
soundflix committed Dec 12, 2021
1 parent 5a22299 commit b4d8b4c
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 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 host: NWEndpoint.Host
public 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 b4d8b4c

Please sign in to comment.