DittoBusStream
public class DittoBusStream : Identifiable
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 }
-
An ID unique to the local device that can be used to track this individual stream.
Declaration
Swift
public var id: UInt64 { 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()