ConnectionState
@frozen
public enum ConnectionState : Codable, Equatable, CustomStringConvertible
A value representing the connection state of the web socket.
-
Indicates that the web socket is connected.
The associated value is the time offset in milliseconds of the back-end relative to the device. A positive value (respectively a negative value) indicates that the back-end time is ahead of (respectively behind) the device time.
Declaration
Swift
case connected(backEndTimeOffsetMS: Int) -
Indicates that the web socket is unconnected.
The first associated value is the last known, if any, time offset in milliseconds of the back-end relative to the device. It is
nilor non-nildepending on whether the web socket has already been connected or not. A positive value (respectively a negative value) indicates that the back-end time is ahead of (respectively behind) the device time.The second associated value indicates whether the web socket is initializing. Each time the
DatasyncService.isConnectionEnabledproperty becomestrue, including when opening the web socket atDatasyncServiceinitialization, this associated value becomestrueand the web socket tries to connect to the back-end. It becomesfalseagain as the soon as this connection attempt is concluded, whether it succeeded or failed. In case of success, this connection state becomes.connected(backEndTimeOffsetMS:). In case of failure, it remains.disconnected(backEndTimeOffsetMS:isInitializing:).Declaration
Swift
case disconnected(backEndTimeOffsetMS: Int?, isInitializing: Bool)
-
Declaration
Swift
public init(from decoder: Decoder) throws
-
Declaration
Swift
public func encode(to encoder: Encoder) throws
-
The time offset in milliseconds of the back-end relative to the device.
A positive value (respectively a negative value) indicates that the back-end time is ahead of (respectively behind) the device time.
This property is non-
nilwhen this value matches the.connected(backEndTimeOffsetMS:)case. This property may benilor non-nilwhen this value matches the.disconnected(backEndTimeOffsetMS:isInitializing:)case, depending on whether the web socket has already been connected or not.Declaration
Swift
public var backEndTimeOffsetMS: Int? { get } -
Converts a back-end-related date to a device-related date.
This method adjusts the
backEndDateby subtractingbackEndTimeOffsetMSfrom it.Declaration
Swift
public func deviceDate(for backEndDate: Date) -> Date?Parameters
backEndDateThe back-end-related date to convert.
Return Value
The device-related-date corresponding to
backEndDate, ornilwhenbackEndTimeOffsetMSis itselfnil. -
Converts a back-end-related date to a device-related date.
This method adjusts the
backEndDateby subtractingbackEndTimeOffsetMSfrom it.Declaration
Swift
public func deviceDate(for backEndDate: WebcomDate) -> Date?Parameters
backEndDateThe back-end-related date to convert.
Return Value
The device-related-date corresponding to
backEndDate, ornilwhenbackEndTimeOffsetMSis itselfnil.
-
Declaration
Swift
public var description: String { get }