subscribe method

void subscribe({
  1. required String topic,
})

Subscribe to a given topic.

Implementation

void subscribe({required String topic}) {
  final data = {
    'topic': topic,
    'type': 'sub',
    'payload': '',
    'silent': true,
  };

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