send method

void send(
  1. EventDTO dto
)

Sends an event to the node if the data type matches T. Updates the lastData and adds the event to the stream.

Implementation

void send(EventDTO dto) {
  if (dto.data is T) {
    var previous = lastData;
    var d = EventDTO<T>(dto.data, topic: dto.topic, completer: dto.completer);
    lastData = dto.data;
    _streamController.add(_NodeEvent<T>(d, previous));
  } else {
    // an event of a foreign type: it must not be dropped silently, otherwise
    // the sender would never get an answer
    _completeIfNeeded(dto.completer, null);
  }
}