send method

WaitingMessage send(
  1. String event,
  2. Map<String, dynamic> payload
)
inherited

Send an event with a payload to this PubSub. PubSub ensures each event will be received in onReceive exactly once. This will return a waiting message that gets resolved as soon as it has been received on the server. Use .addListener to wait for messages to resolve.

Implementation

WaitingMessage send(String event, Map<String, dynamic> payload) {
  WaitingMessage waitingMessage =
      PubSubSupervisor.sendMessage(this, event, payload);

  if (!waitingMessage.resolved) {
    waitingMessage.addListener(() {
      waitingMessages.remove(waitingMessage.hashCode);
    });
  } else {
    waitingMessages[waitingMessage.hashCode] = waitingMessage;
  }

  return waitingMessage;
}