unsubscribe<T> method
Removes a subscriber from the Stream associated with the subscription.
Implementation
Future<void> unsubscribe<T>(final WebSocketSubscription<T> subscription) async {
await subscription.cancel();
final StreamController? controller = _controller(subscriptionId: subscription.id);
if(controller != null && !controller.hasListener) {
assert(controller.stream.isBroadcast); // close() will never complete for non-broadcast
await controller.close(); // streams that are never listened to.
_subscriptionIdToController.remove(subscription.id);
}
}