DittoBusStream

public class DittoBusStream : Identifiable, Equatable, Hashable

A message-based communication channel to another peer in the mesh.

When a DittoBusStream is received by any means, you must immediately set a delegate. This provides the notifications of incoming messages and other events.

Outgoing messages can be enqueued using enqueueMessage. You must wait for the delegate method indicating that the enqueue was successful before calling this method again. This process provides backpressure so that your app does not send data more quickly than the network can deliver.

  • Delegate for events relating to this stream.

    This must be set to a non-nil value as soon as you obtain this stream, either by opening a stream or by having an incoming stream arrive.

    Declaration

    Swift

    public weak var delegate: DittoBusStreamDelegate? { get set }
  • id

    An ID unique to the local device that can be used to track this individual stream.

    Declaration

    Swift

    public var id: UInt64 { get }
  • True if enqueueMessage may be called at this time and false if there is a send pending.

    Consider using DittoBusStreamDelegate to be informed when the enqueue operation has completed.

    Declaration

    Swift

    public var isReady: Bool { get }
  • The reliability mode under which this stream is operating.

    Declaration

    Swift

    public var reliability: DittoBusReliability { get }
  • Enqueue a message to be sent to the other peer.

    You must wait for the delegate method indicating that enqueuing was successful before calling this again.

    Declaration

    Swift

    public func enqueueMessage(data: Data)
  • Close this stream in both directions.

    It is recommended to call this when finished with the stream. Alternatively if the instance is deallocated then it will be closed automatically.

    Declaration

    Swift

    public func close()
  • Declaration

    Swift

    public static func == (lhs: DittoBusStream, rhs: DittoBusStream) -> Bool
  • Declaration

    Swift

    public func hash(into hasher: inout Hasher)