DITBusStream

@interface DITBusStream : NSObject

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.

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

    Declaration

    Objective-C

    @property (nonatomic, readonly) uint64_t streamID;
  • The reliability mode under which this stream is operating.

    Declaration

    Objective-C

    @property (nonatomic, readonly) DITBusReliability reliability;
  • YES if enqueueMessage may be called at this time and NO if there is a send pending.

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

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL isReady;
  • 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

    Objective-C

    @property (nonatomic, weak, nullable) id<DITBusStreamDelegate> delegate;
  • 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

    Objective-C

    - (void)enqueueMessage:(nonnull NSData *)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

    Objective-C

    - (void)close;