HYPNetworkObserver

@protocol HYPNetworkObserver

Network observers handle network events, such as instances being found and lost on the network.

  • This notification is issued when an instance is found with a matching app identifier. Instances on direct link are automatically resolved, while instances found in mesh may not be. If the given instance is already resolved, communicating with it is already possible, but attempting to do so should only happen after a notification to the -hypeDidResolveInstance: delegate callback. The app should resolve all instances that it wants to communicate when this notification is triggered.

    Declaration

    Objective-C

    - (void)hypeDidFindInstance:(HYPInstance *)instance;

    Swift

    func hypeDidFind(_ instance: HYPInstance!)

    Parameters

    instance

    The found instance.

  • This notification is issued when a previously found instance is lost, such as it going out of range, or the adapter being turned off. The error parameter indicates the cause for the loss. When a cause cannot be properly determined the framework uses a probable one instead, usually indicating that the device appeared to go out of range.

    Declaration

    Objective-C

    - (void)hypeDidLoseInstance:(HYPInstance *)instance error:(HYPError *)error;

    Swift

    func hypeDidLose(_ instance: HYPInstance!, error: HYPError!)

    Parameters

    instance

    The lost instance.

    error

    An error describing the cause for the loss.

  • This notification indicates that the given instance has already been resolved and is thus ready to communicate. The instance’s announcement and user identifier should help identify the user running the app. The app should keep track of resolved instances, and clear them when they are lost, as these instances are necessary in order to send messages.

    Declaration

    Objective-C

    - (void)hypeDidResolveInstance:(HYPInstance *)instance;

    Swift

    func hypeDidResolve(_ instance: HYPInstance!)
  • This delegate notification indicates that resolving an instance was not possible. There are many scenarios under which that may happen, but they are usually uncommon. A notable case is when the instance is lost during the handshake process, invalidating it.

    Declaration

    Objective-C

    - (void)hypeDidFailResolvingInstance:(HYPInstance *)instance
                                   error:(HYPError *)error;

    Swift

    func hypeDidFailResolving(_ instance: HYPInstance!, error: HYPError!)

    Parameters

    instance

    The instance that could not be resolved.

    error

    An error indicating the cause for the failure.