Starscream: What is the purpose of case .viabilityChanged

Created on 19 Jun 2020  路  4Comments  路  Source: daltoniam/Starscream

I have received this from the websocket, but I have no idea what is this for? Why does this happen?

All 4 comments

+1 for this question. the only evidence I could found now is that when you are connected to socket, and you turn of the internet connection, it'll trigger viabilityChanged event

Found a little comment in Transport.swift, I think this could explain the usage of this enum

Screen Shot 2020-06-28 at 22 42 13

It is forwarded from this update handler in Apple's "Network" framework:
https://developer.apple.com/documentation/network/nwconnection/2998578-viabilityupdatehandler

From the docs:

    /// Set a block to be called when the connection's viability changes, which may be called
    /// multiple times until the connection is cancelled.
    ///
    /// Connections that are not currently viable do not have a route, and packets will not be
    /// sent or received. There is a possibility that the connection will become viable
    /// again when network connectivity changes.
    final public var viabilityUpdateHandler: ((Bool) -> Void)?

false indicates that it can't send/receive packets, true indicates that it can now send/receive packets. You can do whatever you want with that information! You could attempt to reconnect, show an offline warning to the user, etc.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LondonAtlas picture LondonAtlas  路  3Comments

CRoig picture CRoig  路  6Comments

milanstevanovic picture milanstevanovic  路  5Comments

adrian-niculescu picture adrian-niculescu  路  4Comments

francos picture francos  路  3Comments