iOS HMLocalDeviceDelegate
HMLocalDeviceDelegate is used to dispatch HMLocalDevice's events. All invocations are executed on the main thread.
Methods
State changed to a new one
Declaration
func localDevice(stateChanged newState: HMLocalDeviceState, oldState: HMLocalDeviceState)
Parameters
newState | (HMLocalDeviceState) the new state |
oldState | (HMLocalDeviceState) previous state |
Read More
Example
import HMKit
extension SomeType: HMLocalDeviceDelegate {
/*
Other required methods implementation
*/
func localDevice(stateChanged newState: HMLocalDeviceState, oldState: HMLocalDeviceState) {
switch (newState, oldState) {
case (.broadcasting, _):
print("Device started broadcasting.")
case (.idle, .broadcasting):
print("Device stopped broadcasting.")
default:
break
}
}
}
A connection to an HMLink was received
Declaration
func localDevice(didReceiveLink link: HMLink)
Parameters
link | (HMLink) the connected Link |
Discussion
aaaa
Read More
Example
import HMKit
extension SomeType: HMLocalDeviceDelegate {
/*
Other required methods implementation
*/
func localDevice(didReceiveLink link: HMLink) {
link.delegate = LinkDelegateObject()
print("Connection established.")
}
}
A connection to an HMLink was lost
Declaration
func localDevice(didLoseLink link: HMLink)
Parameters
link | (HMLink) the previously connected HMLink |
Read More
Example
import HMKit
extension SomeType: HMLocalDeviceDelegate {
/*
Other required methods implementation
*/
func localDevice(didLoseLink link: HMLink) {
link.delegate = nil
print("Connection lost.")
}
}