unsubscribe method
- String topic,
- PubSubMessageListener listener
Stops listener receiving topic.
The listener stops at once, even after the room is left; telling the server needs a joined room.
Example
await room.pubSub.unsubscribe("CHAT", chat);
Implementation
Future<void> unsubscribe(String topic, PubSubMessageListener listener) async {
//The local listener is removed unconditionally, before the gate: the usual
//teardown is room.leave() then unsubscribe() in State.dispose(), and a
//listener left bound to a disposed State would call setState() later.
final subscriptions = _subscriptions[topic];
final id = subscriptions?.remove(listener);
if (id == null) return;
if (subscriptions!.isEmpty) _subscriptions.remove(topic);
if (!_ensureJoined("pubSub.unsubscribe")) return;
await _pubsubUnsubscribe(topic, id);
}