Skip to content

Commit

Permalink
Updated readme to the new error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gunter Hager committed Mar 25, 2019
1 parent 2dd7c17 commit 9a03702
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
17 changes: 14 additions & 3 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,23 @@ An example app is included demonstrating UDPBroadcastConnection's functionality.
Create a `UDPBroadcastConnection` on port `35602` with a closure that handles the response:

```swift
broadcastConnection = UDPBroadcastConnection(port: 35602) { [unowned self] (response: (ipAddress: String, port: Int, response: [UInt8])) -> Void in
broadcastConnection = try UDPBroadcastConnection(
port: 35602,
handler: { (response: (ipAddress: String, port: Int, response: [UInt8])) -> Void in
print("Received from \(response.ipAddress):\(response.port):\n\n\(response.response)")
}
},
errorHandler: { (error) in
print(error)
})
```

Note: Make sure to keep a strong reference to `broadcastConnection` (e.g. by storing it in a property).
Note: Make sure to keep a strong reference to `broadcastConnection` (e.g. by storing it in a property) to be able to receive responses.

Send a message via broadcast:

```swift
try broadcastConnection.sendBroadcast("This is a test!")
```


## Installation
Expand Down
3 changes: 0 additions & 3 deletions UDPBroadcast/UDPBroadcastConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,6 @@ open class UDPBroadcastConnection {
}
}

/**
Close the connection.
*/
/// Close the connection.
///
/// - Parameter reopen: Automatically reopens the connection if true. Defaults to true.
Expand Down

0 comments on commit 9a03702

Please sign in to comment.