send method

bool send({
  1. required Map<String, dynamic> payload,
  2. required String topic,
  3. bool silent = false,
})

Send a given payload to the server. The payload is json-encoded before sending.

Implementation

bool send({
  required Map<String, dynamic> payload,
  required String topic,
  bool silent = false,
}) {
  final data = {
    'topic': topic,
    'type': 'pub',
    'payload': json.encode(payload),
    'silent': silent,
  };

  final message = json.encode(data);
  return _socket?.send(message) ?? false;
}